Trying to send mail with an attachment

R

Robert Dufour

I tried using (vs2003 Vb.Net)
Public Sub SendEmail( _

ByVal Recipient As String, _

ByVal Sender As String, _

ByVal Subject As String, _

ByVal Message As String, _

ByVal Server As String, _

Optional ByVal Attachments As String = "")

' Parameters: Recipient - recipient's address (e.g.,
"(e-mail address removed)")

' Sender - sender's email address (e.g., "(e-mail address removed)")

' Subject - text for email subject.

' Message - complete text of body of email message.

' Server - server to use, or blank to use local machine's default

' SMTP server (if applicable).

Dim msg As System.Web.Mail.MailMessage = New System.Web.Mail.MailMessage

' To and From are required by SmtpMail.

msg.To = Recipient

msg.From = Sender

msg.Subject = Subject

msg.Body = Message

msg.BodyFormat = System.Web.Mail.MailFormat.Text

System.Web.Mail.SmtpMail.SmtpServer = Server

System.Web.Mail.SmtpMail.Send(msg)

End Sub

But I can't add an attachment. When I try setting msg.attachments =
attachments I get msg say attcahment property is readOnly



How can I send an e-mail with an attachment from within my code?



Thanks for any help.

Bob
 

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

Top