Results 1 to 2 of 2

Thread: Sending Email Attachments

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jan 2001
    Posts
    1,374

    Sending Email Attachments

    I am trying to send SMTP mail using System.Web.Mail classes.

    Sending text is OK with classes "MailMessage" and "SmtpMail" but I can't work out how to send attachments. The "MailMessage.Attachments" property is read-only.

    There is a class in this group called "MailAttachment" whose constructor sets the attachment file name. I can't see how this connects to the above 2 classes.

    Can you send multiple attachments?

    Also, is there any way of capturing whether the email was sent to an errant address? Sending to an errant address doesn't raise an exception.

  2. #2
    Fanatic Member pax's Avatar
    Join Date
    Mar 2001
    Location
    Denmark
    Posts
    840
    Hi.

    Try this:

    VB Code:
    1. Dim msg As New System.Web.Mail.MailMessage()
    2.         msg.Attachments.Add(New System.Web.Mail.MailAttachment(MyFileName1))
    3.         msg.Attachments.Add(New System.Web.Mail.MailAttachment(MyFileName2))

    And you can keep on adding as many as you want...

    Hope it helps.
    I wish I could think of something witty to put in my sig...

    ...Currently using VS2013...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width