?
Solved

Email HTML Page and Reference Attachment

Posted on 2009-04-30
4
Medium Priority
?
271 Views
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?

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

0
Comment
Question by:ALawrence007
  • 2
  • 2
4 Comments
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 2000 total points
ID: 24273435
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
 

Author Comment

by:ALawrence007
ID: 24281348
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
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 24281398
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
 

Author Closing Comment

by:ALawrence007
ID: 31576545
Thanks CodeCruiser,
I am already using Outlook Interop Assebly. It was actually as easy as adding the attachment and then naming the image.
0

Featured Post

Restore individual SQL databases with ease

Veeam Explorer for Microsoft SQL Server delivers an easy-to-use, wizard-driven interface for restoring your databases from a backup. No expert SQL background required. Web interface provides a complete view of all available SQL databases to simplify the recovery of lost database

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses
Course of the Month14 days, 5 hours left to enroll

809 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