Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2009
    Location
    Ohio, United States
    Posts
    167

    Unanswered: Emailing PDFs Using Access?

    I used Leban's report to pdf and it is working great. However, now I'm not sure how to send the resulting PDF via email. I was thinking I could insert this as a 'sendobject' line in the same macro I used to create the pdfs and merge them into one, however, it looks like it will only allow me to send Access related files. The file location is "H:\Access\Dunning Letters\1DL.pdf". I'm still pretty naive with VB but if I am given a working code, I can usually mess around with it to get it to work. Any advice on this?

    Thanks
    Joshua

  2. #2
    Join Date
    Jun 2004
    Location
    Liverpool, NY USA
    Posts
    2,509
    Code:
    Dim blRet As Boolean
        Dim ObjSendMail
        
        ' lock the fax button until it is done
        DoCmd.Hourglass True
        Me![New Fax Button].ForeColor = RGB(255, 0, 0)
          
        poCheck = DSum("[qty_ord]", "merch_po_ln", "[po_cd] = '" & Forms!frmPartsPO!PO_CD.Value & "'")
        pt0_check = DLookup("[po_srt_cd]", "merch_po", "[po_cd] = '" & Forms!frmPartsPO!PO_CD.Value & "'")
        email = Nz(DLookup("[email]", "[Vendors fax]", "[ve_id] = '" & Forms!frmPartsPO!VE_CD.Value & "'"), "")
        CC_EMAIL = Nz(DLookup("[cc_email]", "[Vendors fax]", "[ve_id] = '" & Forms!frmPartsPO!VE_CD.Value & "'"), "")
        email_from = Nz(DLookup("[email]", "[current user]", "[users] = '" & atCNames(1) & "'"), "parts@raymourflanigan.com")
        PdfFile = "c:\temp\PO_" & Forms!frmPartsPO!PO_CD.Value & ".pdf"
        
          blRet = False
        
             If poCheck <> 0 Then
           If pt0_check <> "PT0" Then
              
              docname = "Report Selected Purchase Order Parts"
              
              blRet = ConvertReportToPDF(docname, vbNullString, PdfFile, False, False, 0, "", "", 0, 0)
     
           Else
              store_check = DLookup("[store_cd]", "merch_po", "[po_cd] = '" & Forms!frmPartsPO!PO_CD.Value & "'")
              
                 If store_check = "00" Then
               
                    srvc_tic_cnt = DCount("[del_doc_num]", "service_tic_cnt_qry")
                    If srvc_tic_cnt > 0 Then
                       docname = "Report Selected Purchase Order Parts2"
                       blRet = ConvertReportToPDF(docname, vbNullString, PdfFile, False, False, 0, "", "", 0, 0)
                    Else
                       MsgBox "No Matching Service Order Exists"
                    End If
                 Else
                 
                    docname = "Report Selected Purchase Order Parts"
                    blRet = ConvertReportToPDF(docname, vbNullString, PdfFile, False, False, 0, "", "", 0, 0)
                 End If
           End If
           If blRet Then
             Set ObjSendMail = CreateObject("CDO.Message")
             
             'This section provides the configuration information for the remote SMTP server.
             
             'Send the message using the network (SMTP over the network).
             ObjSendMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
             ObjSendMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "xxx.xx.x.xx"
             ObjSendMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
             'Use SSL for the connection (True or False)
             ObjSendMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False
             ObjSendMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
             
             ' If your server requires outgoing authentication uncomment the lines below and use a valid email address and password.
             'ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 'basic (clear-text) authentication
             'ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") ="somemail@yourserver.com"
             'ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") ="yourpassword"
             
             ObjSendMail.Configuration.Fields.Update
             
             ObjSendMail.To = email
             ObjSendMail.Subject = "Purchase Order #" & Forms!frmPartsPO!PO_CD.Value
             ObjSendMail.From = email_from
             If CC_EMAIL <> "" Then
               ObjSendMail.CC = CC_EMAIL
             End If
            ' ObjSendMail.BCC = "parts@xxxxxxxx.com"
             ObjSendMail.TextBody = "Please find attached a pdf file for Purchase Order #" & Forms!frmPartsPO!PO_CD.Value & " from xxxxxx & xxxx. Any questions regarding this order, please contact Jennifer Sxxxxxx at ..."
             ObjSendMail.AddAttachment PdfFile
             
        
             ObjSendMail.Send
             
             Set ObjSendMail = Nothing
    
              Kill PdfFile
           End If
    Bill
    You do not need a parachute to skydive. You only need a parachute to skydive twice.

Posting Permissions

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