Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Place a Word doc or a PDF into body of an email using Access 2007 1

Status
Not open for further replies.

1inamil

Programmer
Oct 18, 2002
4
CA
I am automating sending an email from within Access 2007. I can create the email, fill in the To:, Subject: and Body: portions using code (see below) but I also want to insert either a Word doc or a PDF into the body.

------------------------------------------------------------
Public Sub SendFlier(varTo As Variant)
Dim mailItem As Outlook.mailItem

InitOutlook 'Initializes a session in Outlook
Set mailItem = outlookApp.CreateItem(olMailItem)

With mailItem
.To = varTo & ""
.Subject = "Test Subject"
.Body = "This email was automated using MS Access." & Chr(13) & This is where I would like to insert the Word doc or PDF

End With

mailItem.Display

Set mailItem = Nothing

CleanUp 'Cleans up objects
End Sub

---------------------------------------------------------------
Is this possible? So far I haven't figured out a way.
 
Are you trying to insert the content of this .doc/.pdf or add an attachment?

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"

Google Rank Extractor -> Perl beta with FusionCharts
 
Thanks for asking. I want to insert the content into the body.
 
Well firstly you need to parse the PDF or Word doc.

Then depending on if your email is HTML or plain text convert the content to the correct type.

Also remember HTML for emails is different from standards compliant HTML , MS is a nightmare for gettting HTML to display properly as the idiots use Word as the rendering engine in newer versions of Outlook.

Remember .body is a string type so you cannot simply pass it a binary document and expect it to auto parse the content and convert it to email format for you.

Opening a word document and capturing the text if that's all that is in the word doc isn't that difficult.

and perhaps if you have the main word document as an RTF and bind it to rich text box, you could then easily get the textual content.

here is a link to info on how to parse a word doc with VBA
PDF is much tricker, it is a form of mark up and that also needs to be parsed.

Here is a link from the MSDN which might help you
Is there a reason you want to paste the content of these documents into the body of an HTML email?

attaching them is far simpler ;-)

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"

Google Rank Extractor -> Perl beta with FusionCharts
 
I agree, attaching is far simpler. But I'm sending out fliers to companies thru email and many companies strip attachements from email. That won't serve my purpose at all. They need to see it to be effective.
I'll try your suggestion about parsing and let you know how it went.
Thanks for the fast reply! Wasn't expecting anything till later today at the very best.
 
If you want to design the email in word and then send as an email , you need to use the mail envelope wrapper, that's how I do it.

here's the FAQ I wrote on the subject, it might help faq705-6950




"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"

Google Rank Extractor -> Perl beta with FusionCharts
 
Thanks a million.
I was at the point yesterday where I was giving up on Access and looking at Word's email merge to handle it. I like your solution!
 
just remember, we are talking about using word to design an email and then send via outlook.

MS sucks at this kind of thing, so expect a few funky results.

Also ensure you set the word template to 'Web Layout' as the view.

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"

Google Rank Extractor -> Perl beta with FusionCharts
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top