Here is the function to send mail. Be sure to use System.Web.Mail namespace.
Prodip Saha
public bool SendSMTPMail(string strSMTPServer, string strFrom, string strTo,
string strSubject, string strBody, string strCC, string strBCC, string
strAttachmentList, 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.BodyFormat=MailFormat.Html;
}
else
{
objMsg.BodyFormat=MailFormat.Text;
}
// Build an IList of mail attachments.
//A list of files separated by comma(,)
if (strAttachmentList != "")
{
char[] delim = new char[] {','};
foreach (string sSubstr in strAttachmentList.Split(delim))
{
MailAttachment attachment = new MailAttachment(sSubstr);
objMsg.Attachments.Add(attachment);
}
}
SmtpMail.SmtpServer = strSMTPServer;
SmtpMail.Send(objMsg);
blnTemp=true;
return blnTemp;
}
catch(Exception ex)
{
throw ex;
}
}
"Farooq Khan" <fa*********@pk.softechww.com> wrote in message
news:eJ**************@TK2MSFTNGP12.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(EmailFrom.ToString(), EmailTo.ToString(), Subject.ToString(),
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