What is wrong here?

Discussion in 'ASP .Net Web Services' started by Andrew, Oct 5, 2004.

  1. Andrew

    Andrew Guest

    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.
     
    Andrew, Oct 5, 2004
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. George Hester

    Try over here likely more to the point here

    George Hester, Sep 30, 2004, in forum: Javascript
    Replies:
    0
    Views:
    121
    George Hester
    Sep 30, 2004
  2. FAQ server
    Replies:
    0
    Views:
    162
    FAQ server
    Aug 10, 2006
  3. FAQ server
    Replies:
    0
    Views:
    137
    FAQ server
    Oct 7, 2006
  4. FAQ server
    Replies:
    0
    Views:
    157
    FAQ server
    Dec 4, 2006
  5. FAQ server
    Replies:
    7
    Views:
    144
    Dr J R Stockton
    Feb 10, 2007
Loading...

Share This Page