Call email Client from VB.NET Windows Application

Jefferson

Member
Joined
Aug 16, 2005
Messages
21
Programming Experience
Beginner
Hi Guys,

How would i call and email from vb.net windows forms and attach a document to send to a specified address???
I can't find anything in the help file.

Jefferson
 
Outlook

Hi,

This is what i have found so far, but it does no seem to register the
the parts marked in red.

Private Sub mnuDBEmail_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuDBEmail.Click
Dim oOutlook As New Outlook.Application
Dim oMailitem As Outlook.MailItem
Dim oAttach As Outlook.Attachment
oMailitem = oOutlook.CreateItem(Outlook.OlItemType.olMailItem)
oMailitem.To = "johndoe@somewhere.com"
oMailitem.Subject = "My Subject"
Try
oMailitem.Attachments.Add("C:\TEST.TXT")
Catch ex As Exception
End Try
oMailitem.Send()
End Sub

Do i need to get ahold of a Addin, Dll or some type of file?
Will this work for all Outlook Clients (2K, 2003, etc)
Please help, i am almost done with my project, this is the last section.

 
Hey Jefferson,

I believe you need to add a reference to "Microsoft Outlook 9.0 Object Library".

Hope this helps

Ed: If you want this to work with all the versions you mentioned you may have to use an earlier version of the interop, but you should be ok.

Ed: Blimey a lot of edits... Also you don't have to use outlook, have a look at System.Web.Mail.SmtpMail, or just type SMTPmail into help. (You will need to take the users smtp though)
 
SMTP problems

Hi BadgerByte,

I got the mail to work, and can see it in the sent box of Outlook, But it does not get to the address it should.
Do i need to add SMTP / POP3 settings???

Rgds
Jefferson
 
Back
Top