sending mail messages with attachments

  • Thread starter Thread starter larry mckay
  • Start date Start date
L

larry mckay

I'm trying to send mail using the
mail.smptserver,
mailmessage,
mailattachment objects

I'm having trouble assigning an attachment to before doing an smpt.send
using vb.net

does anyone have any coding samples on how to programatically add mail
attachments using .net
 
* larry mckay said:
I'm trying to send mail using the
mail.smptserver,
mailmessage,
mailattachment objects

I'm having trouble assigning an attachment to before doing an smpt.send
using vb.net

does anyone have any coding samples on how to programatically add mail
attachments using .net

\\\
....
mailmsg.Attachments.Add(New MailAttachment(<Path>))
SmtpMail.Send(mailmsg)
///
 
Hi Larry,

This worked fine for me:
Dim msg As New MailMessage()

msg.To = "(e-mail address removed)"

msg.From = "(e-mail address removed)"

msg.Subject = "test subject"

msg.Body = "this is the test info"

Dim astring1 As String = "c:\my documents\wzo letter.doc"

msg.Attachments.Add(New MailAttachment(astring1))

Dim astring2 As String = "c:\my documents\visual basic notes.doc"

msg.Attachments.Add(New MailAttachment(astring2))

msg.Cc = "(e-mail address removed)"

SmtpMail.SmtpServer = "smtp.registeredsite.com"

Try

SmtpMail.Send(msg)

Catch ex As Exception

MessageBox.Show(ex.Message)

End Try

HTH,

Bernie Yaeger
 
Back
Top