emailing in ASP.NET

F

Farooq Khan

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
 
F

Farooq Khan

i have even tried using Web.SmtpMail class' send() method for this.....but
it throws "Could not access 'CDO.Message' object." exception.
 
H

Hans Kesting

Farooq Khan said:
i have even tried using Web.SmtpMail class' send() method for this.....but
it throws "Could not access 'CDO.Message' object." exception.

This "Could not access" message seems to be a general error message. The
system
usually CAN access that message object, the problem is further down.
Somewhere in the InnerException list there are probably more useful
errormessages.

Hans Kesting
 
P

Prodip Saha

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;
}
}
 
F

Farooq Khan

thanks saha,
but it doesn't work either. infact that's exactly what i have been doing.
dont know what is wrong with it. anyway thanks for ur help.

Farooq Khan


Prodip Saha said:
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 said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top