By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,652 Members | 1,182 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,652 IT Pros & Developers. It's quick & easy.

emailing a PDF file created by Access...

P: n/a
MLH
I print to a device that creates a PDF. Knowing the filename, how can
I then embed the PDF into the body text of an OutLook Express outbound
email & send to a specified address in a table? I want recipient
addressees to see the report in the body text window of their email
when they open it. I was thinking also about attaching the PDF file to
the eMail for those having "text only" email software. I need to
automate both of these tasks from a VB procedure. IDEAS?
Nov 12 '05 #1
Share this Question
Share on Google+
10 Replies


P: n/a
MLH <CR**@NorthState.net> wrote:
I print to a device that creates a PDF. Knowing the filename, how can
I then embed the PDF into the body text of an OutLook Express outbound
email & send to a specified address in a table? I want recipient
addressees to see the report in the body text window of their email
when they open it. I was thinking also about attaching the PDF file to
the eMail for those having "text only" email software. I need to
automate both of these tasks from a VB procedure. IDEAS?


AFAIK you can't embed a file in the body of an email. You will need to create the
HTML/text as a string yourself using much VBA code.

To create a formatted document to send as an email you will need to use VBA code to
create a largish string. This string will then be passed to the SendObject command
as the body of the email. For more details including sample air code see my Tips
page on this topic at www.granite.ab.ca/access/emailformatted.htm.

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Nov 12 '05 #2

P: n/a
Tony, Thanks for this response. I have a similar challenge, except
that all I want to do is insert and HTML encoded message into Outlook
in such a way that the HTML is rendered properly for display when the
message is sent, just like it would be if you switched to HTML mode in
Outlook and entered the message manually complete with all formatting,
colors, fonts, etc. Right now I'm able to send text messages
(including HTML code to Outlook from an Access 2K procedure that uses
late binding to manipulate the OL object moc\del. But when I send
HTML code to Outlook, the HTML tags all appear in the body of the
message instead of being converted to readable format. I DO have
Outlook set up to default to HTML for new messages.

Any suggestions?

Thanks for your excellent contributions to this group.

--WC

On Sat, 06 Sep 2003 21:54:42 GMT, Tony Toews <tt****@telusplanet.net>
wrote:
MLH <CR**@NorthState.net> wrote:
I print to a device that creates a PDF. Knowing the filename, how can
I then embed the PDF into the body text of an OutLook Express outbound
email & send to a specified address in a table? I want recipient
addressees to see the report in the body text window of their email
when they open it. I was thinking also about attaching the PDF file to
the eMail for those having "text only" email software. I need to
automate both of these tasks from a VB procedure. IDEAS?


AFAIK you can't embed a file in the body of an email. You will need to create the
HTML/text as a string yourself using much VBA code.

To create a formatted document to send as an email you will need to use VBA code to
create a largish string. This string will then be passed to the SendObject command
as the body of the email. For more details including sample air code see my Tips
page on this topic at www.granite.ab.ca/access/emailformatted.htm.

Tony


Nov 12 '05 #3

P: n/a
MLH <CR**@NorthState.net> wrote in message news:<gk********************************@4ax.com>. ..
I print to a device that creates a PDF. Knowing the filename, how can
I then embed the PDF into the body text of an OutLook Express outbound
email & send to a specified address in a table? I want recipient
addressees to see the report in the body text window of their email
when they open it. I was thinking also about attaching the PDF file to
the eMail for those having "text only" email software. I need to
automate both of these tasks from a VB procedure. IDEAS?


Express does not expose any objects, so you cannot automate it
directly. You might be able to do it using the CDO libraries or
something. You should be able to find something like that at the MS
website. Look for something like "CDONTS.DLL". If I remember right,
it's just a MAPI wrapper, so it should work. Then once you have that
installed and registered, doing what you ask is trivial.

In a sub/function do the following:
Create a new mail message.
Specify the body text. Not sure how you'd paste in the PDF, though.
If you were adding normal text, it would be a snap.
Add any attachments you want. (the PDF)
specify the recipients... open a recordset of recipients inside your
function (or pass it in as an argument), then loop through them adding
them to the Recipients collection.
When everything is the way you want it, issue the .Send command of the
message object.
Nov 12 '05 #4

P: n/a
Pieter, Thanks for this response. I have a similar challenge, except
that all I want to do is insert and HTML encoded message into Outlook
in such a way that the HTML is rendered properly for display when the
message is sent, just like it would be if you switched to HTML mode in
Outlook (not Outlook Express) and entered the message manually
complete with all formatting, colors, fonts, etc. Right now I'm able
to send text messages (including HTML code to Outlook from an Access
2K procedure that uses late binding to manipulate the OL object
moc\del. But when I send HTML code to Outlook, the HTML tags all
appear in the body of the message instead of being converted to
readable format. I DO have Outlook set up to default to HTML for new
messages.

Any suggestions?

--WC

On 6 Sep 2003 15:13:33 -0700, pi********@hotmail.com (Pieter Linden)
wrote:
MLH <CR**@NorthState.net> wrote in message news:<gk********************************@4ax.com>. ..
I print to a device that creates a PDF. Knowing the filename, how can
I then embed the PDF into the body text of an OutLook Express outbound
email & send to a specified address in a table? I want recipient
addressees to see the report in the body text window of their email
when they open it. I was thinking also about attaching the PDF file to
the eMail for those having "text only" email software. I need to
automate both of these tasks from a VB procedure. IDEAS?


Express does not expose any objects, so you cannot automate it
directly. You might be able to do it using the CDO libraries or
something. You should be able to find something like that at the MS
website. Look for something like "CDONTS.DLL". If I remember right,
it's just a MAPI wrapper, so it should work. Then once you have that
installed and registered, doing what you ask is trivial.

In a sub/function do the following:
Create a new mail message.
Specify the body text. Not sure how you'd paste in the PDF, though.
If you were adding normal text, it would be a snap.
Add any attachments you want. (the PDF)
specify the recipients... open a recordset of recipients inside your
function (or pass it in as an argument), then loop through them adding
them to the Recipients collection.
When everything is the way you want it, issue the .Send command of the
message object.


Nov 12 '05 #5

P: n/a
On Sat, 06 Sep 2003 23:31:14 GMT, Chuck Grimsby
<c.*******@worldnet.att.net.invalid> wrote:

Chuck,

Thanks tons for your prolific effort here. I am remiss in allowing
you to think it was more complicated than it was. As it turns out,
all I had to do was to change the .body property to the .HTMLBody
property and wham -- it worked like a champ! I always feel a little
foolish when I discover a solution after I've been stumped for a
while. After 22 years in the IT business, I still get stumped by
these computers now and then.

The only way to do this William, is to "build" a HTML page on your
drive (preferably in the *user's* temp directory), then read it back
in as a string to place in the .Body property of the OutLook message.
You may want to visit http://www.slipstick.com/ for some examples.
(It's been a while since I've been there, so I'm not certain that they
have any, but they used to. CDOHelp.org used have code samples as
well, and probably the *best* set of examples of how to do anything
with Outlook, but they seem to be gone now.)

A far simpler way to do this would be to build your own SMTP server in
Access so you don't have to bother with the user's EMail program at
all. Search this newsgroup at Google for SMTP and you'll find code
that I've posted in the past that does this. (It's very simple,
actually! I just hate posting the same code over and over again...)

If you're unfamiliar with creating valid HTML pages, find someone who
is, who can hopefully build you a "example" page that you can use as a
template. (If you have to build this yourself, visit
http://www.htmlgoodies.com/ for help in how to do basic web pages.
It's a great beginner's site.)

You will have to also .Attachment the PDF file, and any graphic images
you want to appear as well.

With the above in mind, I want to caution you about a few things.
First (if you insist on using OutLook), make sure your EMail server
will allow you to send files as large as you are going to be sending
out. Not all EMail servers do! Nor do all EMail servers allow
*incoming* messages that are over a certain size.

Some EMail servers won't allow HTML messages of any kind due to all
the viruses that target OutLook users. Turning off HTML EMail is
usually the safest (and cheapest) way to deal with the virus problem,
so it's becoming more and more popular. Some users turn this off
themselves as well.

Lastly, if the information you are sending out is in *any* way
confidential, remember that EMail is *NOT* secure in any way, shape or
form. Unless the PDF file you are sending is Read password protected
(the user has to type in a password to see what's in the file), you
could not only be breaking several laws, but also be setting yourself
(and/or your company) up for quite a lawsuit which you will have no
hope whatsoever of winning.

On Sat, 06 Sep 2003 17:26:02 -0500, William Case <No@address.com>
wrote:
Pieter, Thanks for this response. I have a similar challenge, except
that all I want to do is insert and HTML encoded message into Outlook
in such a way that the HTML is rendered properly for display when the
message is sent, just like it would be if you switched to HTML mode in
Outlook (not Outlook Express) and entered the message manually
complete with all formatting, colors, fonts, etc. Right now I'm able
to send text messages (including HTML code to Outlook from an Access
2K procedure that uses late binding to manipulate the OL object
moc\del. But when I send HTML code to Outlook, the HTML tags all
appear in the body of the message instead of being converted to
readable format. I DO have Outlook set up to default to HTML for new
messages.

On 6 Sep 2003 15:13:33 -0700, pi********@hotmail.com (Pieter Linden)
wrote:

MLH <CR**@NorthState.net> wrote in message news:<gk********************************@4ax.com>. ..
I print to a device that creates a PDF. Knowing the filename, how can
I then embed the PDF into the body text of an OutLook Express outbound
email & send to a specified address in a table? I want recipient
addressees to see the report in the body text window of their email
when they open it. I was thinking also about attaching the PDF file to
the eMail for those having "text only" email software. I need to
automate both of these tasks from a VB procedure. IDEAS?Express does not expose any objects, so you cannot automate it
directly. You might be able to do it using the CDO libraries or
something. You should be able to find something like that at the MS
website. Look for something like "CDONTS.DLL". If I remember right,
it's just a MAPI wrapper, so it should work. Then once you have that
installed and registered, doing what you ask is trivial.In a sub/function do the following:
Create a new mail message.
Specify the body text. Not sure how you'd paste in the PDF, though.
If you were adding normal text, it would be a snap.
Add any attachments you want. (the PDF)
specify the recipients... open a recordset of recipients inside your
function (or pass it in as an argument), then loop through them adding
them to the Recipients collection.
When everything is the way you want it, issue the .Send command of the
message object.


Nov 12 '05 #6

P: n/a
You can do this easily with Outlook.
Outlook Express doesn't support vba.

Do you have Outlook?
Do you want sample code for Outlook?

Geoff

See www.slipstick.com
Nov 12 '05 #7

P: n/a
William Case <No@address.com> wrote:
As it turns out,
all I had to do was to change the .body property to the .HTMLBody
property and wham -- it worked like a champ!


I want you to know that I posted my previous reply before I looked down to see this
posting. <smile>

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Nov 12 '05 #8

P: n/a
On Sun, 07 Sep 2003 02:49:41 GMT, Tony Toews <tt****@telusplanet.net>
wrote:
William Case <No@address.com> wrote:
Tony, Thanks for this response. I have a similar challenge, except
that all I want to do is insert and HTML encoded message into Outlook
in such a way that the HTML is rendered properly for display when the
message is sent, just like it would be if you switched to HTML mode in
Outlook and entered the message manually complete with all formatting,
colors, fonts, etc. Right now I'm able to send text messages
(including HTML code to Outlook from an Access 2K procedure that uses
late binding to manipulate the OL object moc\del. But when I send
HTML code to Outlook, the HTML tags all appear in the body of the
message instead of being converted to readable format. I DO have
Outlook set up to default to HTML for new messages.

Any suggestions?


An excellent question. <insert sounds of hemming and hawwing> That is a question
I've meant to find an answer to myself have haven't yet bothered as I haven't
required it.

Hmm, when I look at the source for a HTML email I see the following in the body.

<x-html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
.... etc.
</html>
</x-html>

Is it sufficient to put that in there?

No that isn't. The difference is in the header. The plain text email has
Content-Type: text/plain; charset="us-ascii"; format=flowed
while the HTLM email has:
Content-Type: multipart/alternative;
boundary="=====================_164560275==_.ALT"

And you can only manipulate headers by using whatever attributes you can access via
automation or whatever. Not by changing the body of the text.

Hmm, so there is likely some kinda Outlook setting which explicitly states that this
email will be sent as HTML.

Aha, yes there is. HTMLBody.
Thanks for your excellent contributions to this group.


Thanks for your comments. They make the effort worthwhile.

Tony


Thanks again Tony. I discovered this property with help from another
MVP just about two hours before seeing this message. I don't know why
I overlooked it before except that I've never NEEDED it before and I
did not know what string to search for in the Object Browser. I tried
it and it works like a champ.
Nov 12 '05 #9

P: n/a
MLH
Unfortunately, I'm locked into doing this with
outlook express. I can, however, settle for the
attachment. And, yes! I would really appreciate
the sample code for automating the sending
process of some cut 'n paste body text and
an attachment.

If its not too much code to post here, that is.

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

On Sat, 6 Sep 2003 18:55:18 +0100, "Geoff"
<ge***@NOggppSPAM.fsnet.co.uk> wrote:
You can do this easily with Outlook.
Outlook Express doesn't support vba.

Do you have Outlook?
Do you want sample code for Outlook?

Geoff

See www.slipstick.com


Nov 12 '05 #10

P: n/a
MLH <CR**@NorthState.net> wrote:
Unfortunately, I'm locked into doing this with
outlook express. I can, however, settle for the
attachment. And, yes! I would really appreciate
the sample code for automating the sending
process of some cut 'n paste body text and
an attachment.


There's some links to MAPI code at the Access Email FAQ at my website.

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Nov 12 '05 #11

This discussion thread is closed

Replies have been disabled for this discussion.