Create and send an email from Outlook

J Trahair

Well-known member
Joined
May 14, 2008
Messages
175
Location
Spain
Programming Experience
10+
Hi. I have a customer who wants to send emails to his customer and suppliers with confirmation of order, purchase orders etc. instead of printing them and mailing them (postal strikes in the UK, and threats of more).

I have the following code which works on a Vista machine:
VB.NET:
        'Created Outlook Application object
        Dim OLApp As New Outlook.Application
        'Creating outlook Namespace object
        'Dim OLNameSpace As Outlook.NameSpace

        'creating outlook mailitem
        Dim msg As Outlook.MailItem

        Try
            'Creating newblan mail message
            msg = OLApp.CreateItem(Outlook.OlItems.olMailItem)

            'Profile:

            'Adding recipeints to the mail message
            msg.Recipients.Add("me@my.co.uk")

            'adding subject information to the mail message
            msg.Subject = "Test at " & Now.ToLongTimeString.ToString

            'adding body message information to the mail message
            msg.Body = "This is a test message at " & Now.ToLongTimeString.ToString

            'sending message
            msg.Send()

        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Critical)
        End Try

My customer uses a profile in Outlook, ie. his emails carry his firm's logo and images as part of each email.

How do I cause the ProfileName to be set? In VB6 I can use
VB.NET:
objSession.Logon profileName:="whatever"

Is there a similar method for the VB.Net code?

Thanks in advance.
 
Back
Top