26 Mar 2008

Sending Mail with ASP.NET 2.0(C#)


public Int32 NotifyMail(string strFrom, string strTo , string strCC, string strBCC ,string strSubject, StringBuilder sbMailMsg)
{
//create the mail message
MailMessage mail = new MailMessage();
//set the addresses
mail.From = new MailAddress(strFrom,""); // From Address

//Adding To Address
if ((strTo != null) && (strTo != string.Empty))
{
char[] splitter = { ',' };
Array aToList = strTo.Split(splitter);
for (int i = 0; i < splitter =" {" acclist =" strCC.Split(splitter);" i =" 0;" splitter =" {" abcclist =" strBCC.Split(splitter);" i =" 0;" subject =" strSubject;" sbmailbody =" new" cellspacing="'0'" cellpadding="'5'" width="'900'" align="'center'" border="'0'">");
sbMailBody.Append(" ");
sbMailBody.Append("");
sbMailBody.Append("");
sbMailBody.Append("
" + sbMailMsg + "
");
sbMailBody.Append("© 2007. All rights reserved by STi Inc.");
AlternateView htmlView = AlternateView.CreateAlternateViewFromString(sbMailBody.ToString(), null, "text/html");
//create the LinkedResource (embedded image)
LinkedResource clogo = new LinkedResource(@"c:\Temp\logo.jpg");
clogo.ContentId = "clogo";
LinkedResource tclogo = new LinkedResource(@"c:\Temp\txt.gif");
tclogo.ContentId = "txt";
//add the LinkedResource to the appropriate view
htmlView.LinkedResources.Add(clogo);
htmlView.LinkedResources.Add(txt);
//Adding the views
mail.AlternateViews.Add(htmlView);

//Sending the message
SmtpClient smtp = new SmtpClient("smtp.gmail.com"); //specify the mail server address
smtp.Credentials = new NetworkCredential("user", "pwd");
smtp.DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis;
try
{
smtp.Send(mail);
return 1; // For Successful
}
catch
{
return -1; // For Failure
}
}

2 comments:

Anonymous said...

Good day !.
You may , perhaps curious to know how one can make real money .
There is no initial capital needed You may begin to receive yields with as small sum of money as 20-100 dollars.

AimTrust is what you need
The firm incorporates an offshore structure with advanced asset management technologies in production and delivery of pipes for oil and gas.

It is based in Panama with affiliates everywhere: In USA, Canada, Cyprus.
Do you want to become an affluent person?
That`s your choice That`s what you really need!

I`m happy and lucky, I began to get income with the help of this company,
and I invite you to do the same. If it gets down to select a correct partner who uses your money in a right way - that`s it!.
I make 2G daily, and my first investment was 500 dollars only!
It`s easy to join , just click this link http://qukaconi.freehostyou.com/uduleh.html
and go! Let`s take our chance together to get rid of nastiness of the life

Anonymous said...

Hi!
You may probably be very interested to know how one can make real money on investments.
There is no initial capital needed.
You may commense earning with a sum that usually is spent
for daily food, that's 20-100 dollars.
I have been participating in one project for several years,
and I'm ready to share my secrets at my blog.

Please visit my pages and send me private message to get the info.

P.S. I earn 1000-2000 per daily now.

http://theinvestblog.com [url=http://theinvestblog.com]Online Investment Blog[/url]