Email HTML Page and Reference Attachment

Posted on 2009-04-30
Last Modified: 2012-05-06
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?


Public Shared Sub NewCustEmail(ByVal EmailAddress As String _

                                       , ByVal ReceiptSaveLoc As String)


                Dim outlookapp As Outlook.Application = New Outlook.Application

                Dim outBoxfolder As Outlook.MAPIFolder = outlookapp.GetNamespace("MAPI").GetDefaultFolder _


                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


outlookapp = Nothing

Catch ex As Exception

Throw ex

End Try

        End Sub

Open in new window

Question by:ALawrence007
    LVL 83

    Accepted Solution

    This is done by embeding images into the email body as a linked resource. Here is the link.


    Author Comment

    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?
    LVL 83

    Expert Comment

    To send emails through Outlook, you need to use the Outlook Interop Assebly. Here is an example

    Author Closing Comment

    Thanks CodeCruiser,
    I am already using Outlook Interop Assebly. It was actually as easy as adding the attachment and then naming the image.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
    International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now