A
Andrew
Hi, friends,
I have a function which send email with attachments as the follows:
public int SendEmailWithAttachment(string fromEmailAddress,
string toEmailAddress, string subject, string message, string attachment)
{
System.Web.Mail.MailMessage mm = new System.Web.Mail.MailMessage();
mm.From = fromEmailAddress;
mm.To = toEmailAddress;
mm.Subject = subject;
mm.Body = message;
mm.BodyFormat = System.Web.Mail.MailFormat.Text;
mm.Priority = System.Web.Mail.MailPriority.Normal;
mm.BodyEncoding = System.Text.Encoding.Default;
mm.UrlContentBase = "";
mm.UrlContentLocation = "";
if (attachment.Trim() != "")
{
char[] delim = new char[] {','};
foreach (string sSubstr in attachment.Split(delim))
{
System.Web.Mail.MailAttachment ma = new
System.Web.Mail.MailAttachment(sSubstr);
mm.Attachments.Add(ma);
}
}
System.Web.Mail.SmtpMail.SmtpServer = ""; //default
System.Web.Mail.SmtpMail.Send(mm);
return 1;
}
It works fine if there is only one attachment file. However, if there are
two or more files, I got an error saying:
Could not access 'CDO.Message' object.
But, I really could not find what was wrong. Any ideas, suggestions, etc.?
Thanks a lot.
I have a function which send email with attachments as the follows:
public int SendEmailWithAttachment(string fromEmailAddress,
string toEmailAddress, string subject, string message, string attachment)
{
System.Web.Mail.MailMessage mm = new System.Web.Mail.MailMessage();
mm.From = fromEmailAddress;
mm.To = toEmailAddress;
mm.Subject = subject;
mm.Body = message;
mm.BodyFormat = System.Web.Mail.MailFormat.Text;
mm.Priority = System.Web.Mail.MailPriority.Normal;
mm.BodyEncoding = System.Text.Encoding.Default;
mm.UrlContentBase = "";
mm.UrlContentLocation = "";
if (attachment.Trim() != "")
{
char[] delim = new char[] {','};
foreach (string sSubstr in attachment.Split(delim))
{
System.Web.Mail.MailAttachment ma = new
System.Web.Mail.MailAttachment(sSubstr);
mm.Attachments.Add(ma);
}
}
System.Web.Mail.SmtpMail.SmtpServer = ""; //default
System.Web.Mail.SmtpMail.Send(mm);
return 1;
}
It works fine if there is only one attachment file. However, if there are
two or more files, I got an error saying:
Could not access 'CDO.Message' object.
But, I really could not find what was wrong. Any ideas, suggestions, etc.?
Thanks a lot.