.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Code Snippets >> ASP.NET Controls >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Send SMS Through Mocodile Service in ASP.NET

Posted By:Athira Sreejith       Posted Date: February 22, 2009    Points: 10    Category: ASP.NET Controls    URL: http://www.dotnetspark.com  
 

Send SMS Through Mocodile Service in ASP.NET. This is using third party service Mocodile.

using System;

using System.Data;

using System.Configuration;

using System.Collections;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;

using System.IO;

using RareFind.Model;

using SourceEdge.BCL;

using System.Collections.Generic;

//using System.Configuration;

using SMS_COMAPILib;

using ICSharpCode.SharpZipLib.Zip;

using System.Net;

using System.Reflection;

using System.Data.SqlClient;

using System.Text;

 

string SMSMsg = txtSMSMessage.Text.ToString();

MembersFolderEntity SMSFolderObj = new MembersFolderEntity();

SMSFolderObj.Id = filename.ToString();

SMSFolderObj.Member_Id = getMemID.Id;

SMSFolderObj.MobileNumber = getMemID.Mobile;

SMSFolderObj.UploadedDate = System.DateTime.Today.Date;

SMSFolderObj.Status = true;

//MemFolderObj.To = RecipientMobNo;

SMSFolderObj.From = getMemID.Mobile;

string recMobNo = txtMobNoUpload.Text.ToString();

string[] strRecMobNo = recMobNo.Split(',');

decimal Totalcost = 0;

string AllTo = string.Empty;

string SenderMobNo = getMemID.Mobile;

//string PageQS = getMemID.Id + "*" + MemFolderObj.Id;

//string PageCode = GetPageCode(PageQS);

//PageCode += ".aspx";

string SMSMessage = SMSMsg;

//SMSMessage += "Click on the link :" + " ";

//SMSMessage += "http://208.109.198.92/mocodile/" + PageCode;

for (int i = 0; i < strRecMobNo.Length; i++)

{

string strMobNu = strRecMobNo[i].Trim().ToString();

if (!string.IsNullOrEmpty(strMobNu))

{

bool CheckValid = strMobNu.StartsWith("+");

if (!CheckValid)

{

strMobNu = "+" + strMobNu;

}

decimal Deduct_Cost = MocodileService.GetCost(strMobNu);

try

{

string DllName = MocodileService.GetDllName(strMobNu);

if (!string.IsNullOrEmpty(DllName))

{

string DllPath = Server.MapPath("SMSDLL\\" + DllName);

Assembly AssemblyObj = Assembly.LoadFile(DllPath);

Type[] typs = AssemblyObj.GetTypes();

object obj = Activator.CreateInstance(typs[0]);

bool isSend = ((RareFind.ISMSService)obj).SendSMS(strMobNu, SenderMobNo, SMSMessage);

if (isSend)

{

bool isCreditDeducted = CreditDeduction(getMemID.Id, Deduct_Cost);

if (isCreditDeducted)

{

Totalcost = Totalcost + Deduct_Cost;

}

AllTo += strMobNu + ",";

}

//MemFolderObj.To = AllTo.ToString();

//MemFolderObj.Cost = Totalcost;

//MemFolderObj.Save();

}

}

catch (Exception expSMS)

{

lblMsg.Text = expSMS.Message.ToString();

}

 

}

}

SMSFolderObj.To = AllTo.ToString();

SMSFolderObj.Cost = Totalcost;

bool isSave = SMSFolderObj.Save();

if (isSave)

{

lblMsg.Text = "Message sent sucessfully";

}



     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend