Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

send mail with attachment VB.net

Status
Not open for further replies.

davejam

Technical User
Jan 6, 2004
313
GB
Hi all,

Having a bit of an issue sending email with an attachment from my vb.net application.

From the examples i can find on the web which aren't asp.net related I have tried the following, except in vb.net mailattachment is not defined.

Code:
Imports System.Net.Mail

Dim myMail As New MailMessage()
With insMail
 .From = New MailAddress("me@mysite.com")
 .To.Add("it@mysite.com")
 .Subject = "Test email for attachment"
 .Body = "tester"
 .IsBodyHtml = True
 Dim AttachmentFile As String = my_folder & "file_123.pdf"
 Dim attachment As New MailAttachment(attachmentfile)
 .Attachments.Add(attachment)
end with

but MailAttachment gets an error!
Type 'MailAttachment' is not defined.

Any ideas? or should i try a different approach?

Cheers

daveJam

it works on my machine, so technically i win!
 
FIXED

turns out i was overlooking the obvious!!

Dim MsgAttach As New Attachment(AttachmentFile)
.Attachments.Add(MsgAttach)


daveJam

it works on my machine, so technically i win!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top