Solved

Sending HTML email with MS Access

Posted on 2004-08-19
5
766 Views
Last Modified: 2013-04-04
I am currently developping a MS Access DB under 2000 format.
I have a table containing clients information including e-mail addresses.

Now i want to be able to send email to them.
The email MUST contain images and text formatting. I was hoping to do it with HTML since it's easy and i have experience with that.

I've been trying the DoCmd.SendObject method. Unfortunately, when i send stuff (like a report) in HTML format, it is attached to the main email. I want the HTML to be displayed in the email body.

Also, with the DoCmd.SendObject method, HTML tags specified as the "[message text]" are not parsed in the email client and are simply outputted as "<html><body>..."

I know (and i can figure out) correct algorithms for mass mailing. I want a solution to EASILY send emails with HTML as body.
The mail client should be MS Outlook with very high preference. I was hoping to find a solution which wasn't relying on third party software. Also note that the security confirmation request which appeared in the later MS security patches isn't a problem, I can bear clicking on each of them.
0
Comment
Question by:Zarathushtra
5 Comments
 
LVL 4

Expert Comment

by:naivad
ID: 11849291
You have to specify the outputformat as acFormatRTF

docmd.sendobject(ObjectType, ObjectName, OutputFormat, To, Cc, Bcc, Subject, MessageText, EditMessage, TemplateFile)

The third parameter should be acFormatRTF to use html tags...



0
 
LVL 49

Expert Comment

by:Ryan Chong
ID: 11849791
Try using free vbsendmail component:
http://www.freevbcode.com/ShowCode.Asp?ID=109
0
 
LVL 27

Accepted Solution

by:
jjafferr earned 500 total points
ID: 11850564
Hi Zarathushtra

I have gone throgh this before, and seemed to take the hard way, but I couldn't get through any other way,
So here is my Lengthy way (for the Images, see the End part):



Private Sub Command1_Click()

'1+++++
'You have to output your Report and save it on a disk drive.
'You can do it with HTML to maintain the Report Format.

    DoCmd.OutputTo acOutputReport, "YourReportName", acFormatHTML, "c:\YourReportOutput.HTML", False

'2+++++
'Now we will open this file and read the contenet of it in a String Variable called FullText

Dim MyString
Open "c:\YourReportOutput.HTML" For Input As #1    ' Open file for input.
Do While Not EOF(1)    ' Loop until end of file.
    Line Input #1, MyString    ' Read each Line into MyString variable.
    FullText = FullText & MyString     'Put all the Lines read into one String, FullText
Loop
Close #1    ' Close file.

'3+++++
'In Outlook, go to Tools>Option>Mail Format>HTML (use this message format)
'Why HTML, because the base of it is Text, but the output is formated HTML
'We need to have a String to put in the .HTMLBody, not a file

Dim ol As New Outlook.Application
Dim olMail As Outlook.MailItem

    Set olMail = ol.CreateItem(olMailItem)

    With olMail
        .To = "who@where.com"
        '.CC = strCC
        '.BCC = "address2@aa.com"
        '.Attachments.Add "c:\somefile.txt"
        '.Attachments.Add "c:\somefile2.txt"
        .Subject = "Testing"
        .HTMLBody = FullText '"c:\CVPrint1.HTML"
        '.Body = "This is the body..."
        '.Display
        .Send
    End With

    Set olMail = Nothing
    Set ol = Nothing
End Sub


-----------------

Although a bit long, but it will get your HTML file in the Body of your Outlook Email,
but unfortunatly, Access will not output the images in the Report, so
A way around this is, to upload your images to your server, and point the image in the email to that url, for example:

<IMG height=56 alt="Experts Exchange" src="http://www.experts-exchange.com/images/logo.gif" width=742>


jaffer
0
 

Author Comment

by:Zarathushtra
ID: 11863735
OH!
I just needed to import components =(
0
 
LVL 27

Expert Comment

by:jjafferr
ID: 11863823
Zarathushtra
Why a B grade if it worked for you?
0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

919 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

19 Experts available now in Live!

Get 1:1 Help Now