emailing a PDF file created by Access...

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • MLH

    emailing a PDF file created by Access...

    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?
  • Tony Toews

    #2
    Re: emailing a PDF file created by Access...

    MLH <CRCI@NorthStat e.net> wrote:
    [color=blue]
    >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?[/color]

    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

    Comment

    • William Case

      #3
      Re: emailing a PDF file created by Access...

      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 <ttoews@teluspl anet.net>
      wrote:
      [color=blue]
      >MLH <CRCI@NorthStat e.net> wrote:
      >[color=green]
      >>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?[/color]
      >
      >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[/color]

      Comment

      • Pieter Linden

        #4
        Re: emailing a PDF file created by Access...

        MLH <CRCI@NorthStat e.net> wrote in message news:<gkrjlv01e qnb7kuc3u7vjiir 8ct69n1sia@4ax. com>...[color=blue]
        > 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?[/color]

        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.

        Comment

        • William Case

          #5
          Re: emailing a PDF file created by Access...

          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, pietlinden@hotm ail.com (Pieter Linden)
          wrote:
          [color=blue]
          >MLH <CRCI@NorthStat e.net> wrote in message news:<gkrjlv01e qnb7kuc3u7vjiir 8ct69n1sia@4ax. com>...[color=green]
          >> 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?[/color]
          >
          >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.[/color]

          Comment

          • William Case

            #6
            Re: emailing a PDF file created by Access...

            On Sat, 06 Sep 2003 23:31:14 GMT, Chuck Grimsby
            <c.grimsby@worl dnet.att.net.in valid> 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.

            [color=blue]
            >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:
            >[color=green]
            >>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.[/color]
            >[color=green]
            >>On 6 Sep 2003 15:13:33 -0700, pietlinden@hotm ail.com (Pieter Linden)
            >>wrote:[/color]
            >[color=green][color=darkred]
            >>>MLH <CRCI@NorthStat e.net> wrote in message news:<gkrjlv01e qnb7kuc3u7vjiir 8ct69n1sia@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?[/color][/color]
            >[color=green][color=darkred]
            >>>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.[/color][/color]
            >[color=green][color=darkred]
            >>>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.[/color][/color][/color]

            Comment

            • Geoff

              #7
              Re: emailing a PDF file created by Access...

              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


              Comment

              • Tony Toews

                #8
                Re: emailing a PDF file created by Access...

                William Case <No@address.com > wrote:
                [color=blue]
                >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![/color]

                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

                Comment

                • William Case

                  #9
                  Re: emailing a PDF file created by Access...

                  On Sun, 07 Sep 2003 02:49:41 GMT, Tony Toews <ttoews@teluspl anet.net>
                  wrote:
                  [color=blue]
                  >William Case <No@address.com > wrote:
                  >[color=green]
                  >>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?[/color]
                  >
                  >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.
                  >[color=green]
                  >>Thanks for your excellent contributions to this group.[/color]
                  >
                  >Thanks for your comments. They make the effort worthwhile.
                  >
                  >Tony[/color]

                  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.

                  Comment

                  • MLH

                    #10
                    Re: emailing a PDF file created by Access...

                    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.

                    xxxxxxxxxxxxxxx xxxxxxxxxxxxxxx xxxxxxxxxxxxxxx x



                    On Sat, 6 Sep 2003 18:55:18 +0100, "Geoff"
                    <geoff@NOggppSP AM.fsnet.co.uk> wrote:
                    [color=blue]
                    >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
                    >[/color]

                    Comment

                    • Tony Toews

                      #11
                      Re: emailing a PDF file created by Access...

                      MLH <CRCI@NorthStat e.net> wrote:
                      [color=blue]
                      >Unfortunatel y, 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.[/color]

                      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

                      Comment

                      Working...