Here is the function to send mail. Be sure to use System.Web.Mail namespace.
Prodip Saha
public bool SendSMTPMail(st ring strSMTPServer, string strFrom, string strTo,
string strSubject, string strBody, string strCC, string strBCC, string
strAttachmentLi st, bool blnUseHTML)
{
bool blnTemp=false;
try
{
MailMessage objMsg = new MailMessage();
objMsg.From = strFrom;
objMsg.To = strTo;
objMsg.Subject = strSubject;
objMsg.Body = strBody;
if (strCC !="")
{
objMsg.Cc = strCC;
}
if (strBCC !="")
{
objMsg.Bcc = strBCC;
}
if(blnUseHTML== true)
{
objMsg.BodyForm at=MailFormat.H tml;
}
else
{
objMsg.BodyForm at=MailFormat.T ext;
}
// Build an IList of mail attachments.
//A list of files separated by comma(,)
if (strAttachmentL ist != "")
{
char[] delim = new char[] {','};
foreach (string sSubstr in strAttachmentLi st.Split(delim) )
{
MailAttachment attachment = new MailAttachment( sSubstr);
objMsg.Attachme nts.Add(attachm ent);
}
}
SmtpMail.SmtpSe rver = strSMTPServer;
SmtpMail.Send(o bjMsg);
blnTemp=true;
return blnTemp;
}
catch(Exception ex)
{
throw ex;
}
}
"Farooq Khan" <fa*********@pk .softechww.com> wrote in message
news:eJ******** ******@TK2MSFTN GP12.phx.gbl...
hi,
i'm using CDONTS component for emailing through one of my web service like
this
// Start of code
// 'email' is the CDONTS object name
email.send(Emai lFrom.ToString( ), EmailTo.ToStrin g(), Subject.ToStrin g(),
Body.ToString() , 1)
// End of code
the above call throws an exception with the message saying "Access is
denied.". i'm using Windows 2000 Professional. don't know what i'm doing
wrong over here. help me on this!!!
Thanks.
Farooq Khan