Link to home
Start Free TrialLog in
Avatar of ALawrence007
ALawrence007

asked on

Email HTML Page and Reference Attachment

Hi to all,

I am using the code below to e-mail a sales receipt to my customers. I am creating an HTML page from my SQL database and then saving that to file. I then read the file and place that as the HTML body.

The issue is that not all my users will have access to the internet and I want to display the Images to them as well. At the moment the images are just referenced in the html page. How can I include them?

Thanks

Public Shared Sub NewCustEmail(ByVal EmailAddress As String _
                                       , ByVal ReceiptSaveLoc As String)
            Try
                Dim outlookapp As Outlook.Application = New Outlook.Application
                Dim outBoxfolder As Outlook.MAPIFolder = outlookapp.GetNamespace("MAPI").GetDefaultFolder _
              (Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderOutbox)
                Dim mailItem As Outlook.MailItem = outBoxfolder.Items.Add(Outlook.OlItemType.olMailItem)
 
                mailItem.Subject = "On-line Order Confirmation"
Dim EmailBody As String = System.IO.File.ReadAllText(ReceiptSaveLoc)
mailItem.BodyFormat = Outlook.OlBodyFormat.olFormatHTML
mailItem.HTMLBody = EmailBody
mailItem.To = EmailAddress
mailItem.Send()
outlookapp = Nothing
Catch ex As Exception
Throw ex
End Try
        End Sub

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ALawrence007
ALawrence007

ASKER

CodeCruiser,
Thanks for the answer. That was almost exactly what I needed. I implemented it and it is working, but I am now using .Net mail and not Outlook 2007. I need to be able to use Outlook 2007, because we need a history of e-mails that was sent. Do you maybe know where I might find something like that?
Thanks
To send emails through Outlook, you need to use the Outlook Interop Assebly. Here is an example

http://mytechcorner.wordpress.com/2008/04/30/sending-e-mail-through-outlook-using-vbnet/
Thanks CodeCruiser,
I am already using Outlook Interop Assebly. It was actually as easy as adding the attachment and then naming the image.