Results 1 to 8 of 8
  1. #1
    Join Date
    Jun 2009
    Posts
    89

    Unanswered: Sending PDF Attachment with outlook in HTML

    Hi. I'm trying to send a report from Access with Outlook. At the moment I have:
    Code:
    DoCmd.SendObject acSendReport, "rptRM", acFormatPDF, Nz(Forms![RM]![Email], ""), , , "Rent Schedule"
    This works fine, but the e-mail is in plain text and not in Html, so looks really bad.

    I found microsoft's article about sending with outlook : Using Automation to Send a Microsoft Outlook Message
    with the following code:
    Code:
     Sub SendMessage(DisplayMsg As Boolean, Optional AttachmentPath)
              Dim objOutlook As Outlook.Application
              Dim objOutlookMsg As Outlook.MailItem
              Dim objOutlookRecip As Outlook.Recipient
              Dim objOutlookAttach As Outlook.Attachment
    
              ' Create the Outlook session.
              Set objOutlook = CreateObject("Outlook.Application")
    
              ' Create the message.
              Set objOutlookMsg  = objOutlook.CreateItem(olMailItem)
    
              With objOutlookMsg
                  ' Add the To recipient(s) to the message.
                  Set objOutlookRecip = .Recipients.Add("Nancy Davolio")
                  objOutlookRecip.Type = olTo
    
                 
                 ' Set the Subject, Body, and Importance of the message.
                 .Subject = "This is an Automation test with Microsoft Outlook"
                 .Body = "This is the body of the message." &vbCrLf & vbCrLf
                 .Importance = olImportanceHigh  'High importance
    
                 ' Add attachments to the message.
                 If Not IsMissing(AttachmentPath) Then
                     Set objOutlookAttach = .Attachments.Add(AttachmentPath)
                 End If
    
                 ' Resolve each Recipient's name.
                 For Each ObjOutlookRecip In .Recipients
                     objOutlookRecip.Resolve
                 Next
    
                 ' Should we display the message before sending?
                 If DisplayMsg Then
                     .Display
                 Else
                     .Save
                     .Send
                 End If
              End With
              Set objOutlook = Nothing
          End Sub
    Trouble is, this only attaches an existing file. If I want to attach a report I'm currently viewing, how do i get it to save as pdf and then attach? SendObject is very good at this.

  2. #2
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    You can create the report first and export it to a file in pdf format, then attach this file to your message in Outlook.
    Have a nice day!

  3. #3
    Join Date
    Jun 2009
    Posts
    89
    Any recommenndations as to what function creates PDFs well? Which one does senObject use?

  4. #4
    Join Date
    Jul 2004
    Location
    South Dakota
    Posts
    267
    I use something at work called PrintPDF or Print2PDF. Do a search on the web for PDF printers and you should be able to find something.

    Also, skip the whole Outlook thing I just use CDO (search that as well) to send your emails. That way you don't even need Outlook.

    C

  5. #5
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    If you do not want to pay for Adobe PDF Writer, you may use CutePDF Writer: CutePDF - Create PDF for free, Free PDF Utilities, Save PDF Forms, Edit PDF easily., it's free.
    Have a nice day!

  6. #6
    Join Date
    Jun 2009
    Posts
    89
    It's not the cost that's the problem, it's that I want thsi front end to run on any computer, so don't wnat to install any extras like pdf printers etc.

    And CDO isn't really an option as I want my users to have complete control with an outlook email. THey will not be happy with anything else.

    so we have no access to the code that SendObject uses to create pdfs?

  7. #7
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    The pdf format is not natively supported in any version of the Office suite prior to Office 2007. If you want to work with pdf documents your choices are:
    1. Work with Office 2007 where you can specify the pdf format as an argument of the SendObject method.
    2. Work with a prior version of Office and install a third party component (usually a "pdf printer") that allow you to convert an Office document to the pdf format.

    As for "don't wnat to install any extras like pdf printers etc", I guess you still have to install Office and your front-end on the users computers, so where is the problem?
    Have a nice day!

  8. #8
    Join Date
    Jun 2009
    Posts
    89
    I've already installed office 2007 on every computer. Is there a documentation to the send object method?? surely i can just send it to a temp folder nad then use it as an e-mail attachment?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •