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

ALawrence007Asked:
Who is Participating?
 
CodeCruiserConnect With a Mentor Commented:
This is done by embeding images into the email body as a linked resource. Here is the link.

http://www.codeproject.com/kb/IP/EmailByjebarson.aspx


0
 
ALawrence007Author Commented:
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
0
 
CodeCruiserCommented:
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/
0
 
ALawrence007Author Commented:
Thanks CodeCruiser,
I am already using Outlook Interop Assebly. It was actually as easy as adding the attachment and then naming the image.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.