Results 1 to 5 of 5
  1. #1
    Gina Maylone is offline Always learning
    Windows 7 64bit Access 2013
    Join Date
    Jun 2013
    Location
    Afton, MN
    Posts
    544

    Emailing a PDF

    Hello all,

    Pulling my hair out. I have an email function that works perfectly and I'd prefer not to deviate from it (but will if I have to). However, I'm trying to get the proper name of the attachment I am sending out, currently it's attached as "ProposalReport" where I need it to by the job name and company name (ABC Company Job Name.pdf) which is saved as in a folder on the shared drive. I have tried several things, but just can't get it right. I'm sure it has to do with the line: ObjectName:="ProposalReport", I've tried rewriting it to grab the name of the pdf, but no go.



    Code:
    Dim stDocName As String
    Dim MyPath As String
    'MyPath = (Forms!currentjobs!networkpath & "\" & JobID & " " & JOBNAME & "\Proposals\")
    Dim myreport As String
    
    MyPath = ([Forms]![currentjobs]![saveto] & "\" & [Forms]![currentjobs]![JOBID] & " " & [Forms]![currentjobs]![JOB NAME] & "\Proposals\" & Forms!currentjobs!GCTABLE1.Form.[gc1name])
    stDocName = "ProposalReport"
    myreport = Forms!currentjobs!GCTABLE1.Form.[reportname]
    
    DoCmd.OutputTo acReport, stDocName, acFormatPDF, MyPath + ".pdf", True
    
    'DoCmd.OutputTo acReport, "proposalreport", acFormatPDF, MyPath + ".pdf", True
    
    
    'MyPath = (Forms!currentjobs!FullPath + gc1name + JOBNAME)
    DoCmd.OutputTo acReport, stDocName, acFormatPDF, MyPath + ".pdf", True
    
    
        Dim lngCurrentRow As Integer
        Dim strTo As String
        'Dim strCC As String
        'Dim strBCC As String
        Dim bOK As Boolean
        Dim strsubject As String
        Dim strmessagetext As String
        
        strsubject = "Proposal Attached"
          
        strmessagetext = Forms!currentjobs!GCTABLE1!gc1name & ":" & _
            vbNewLine & vbNewLine & _
            "UAC Proposal Request is attached." & _
            vbNewLine & vbNewLine & _
            "UAC Proposal"
        strTo = Forms!currentjobs!GCTABLE1!Email
        DoCmd.SendObject ObjectType:=acSendReport, _
            ObjectName:="ProposalReport", _
            OutputFormat:=acFormatPDF, _
            To:=strTo, _
            Subject:=strsubject, _
            messagetext:=strmessagetext, _
            EditMessage:=True
    
        'Call SendMsg(strsubject, strmessagetext, strTo)
                   
    Exit_EmailProposals_Click:
        Exit Sub
    
    Err_EmailProposals_Click:
        MsgBox Err.Description
    Thanks in advance for any advice you can offer!

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Have you already tried using a MsgBox or Debug.Print to examine the MyPath string variable? BTW the "&" character is used for concatenation in strings rather than the "+" sign although the "+" sign works but has some unintended consequences unless you expect them.

  3. #3
    Gina Maylone is offline Always learning
    Windows 7 64bit Access 2013
    Join Date
    Jun 2013
    Location
    Afton, MN
    Posts
    544
    Yes, myreport gives me what I want
    Code:
    ?myreport
    ACC Construction Corp. Friday Job Name
    ?stdocname
    ProposalReport
    Thanks!

  4. #4
    Gina Maylone is offline Always learning
    Windows 7 64bit Access 2013
    Join Date
    Jun 2013
    Location
    Afton, MN
    Posts
    544
    Revamped everything. I read that the sendobject method cannot do attachments. So I went with this instead.
    Code:
    Dim stDocName As String
    Dim MyPath As String
    'MyPath = (Forms!currentjobs!networkpath & "\" & JobID & " " & JOBNAME & "\Proposals\")
    MyPath = ([Forms]![currentjobs]![saveto] & "\" & [Forms]![currentjobs]![JOBID] & " " & [Forms]![currentjobs]![JOB NAME] & "\Proposals\" & Forms!currentjobs!GCTABLE1.Form.[reportname])
    stDocName = "ProposalReport"
    
    DoCmd.OutputTo acReport, stDocName, acFormatPDF, MyPath, True
    'DoCmd.OutputTo acReport, "proposalreport", acFormatPDF, MyPath + ".pdf", True
    
    'MyPath = (Forms!currentjobs!FullPath + gc1name + JOBNAME)
    'DoCmd.OutputTo acReport, stDocName, acFormatPDF, MyPath + ".pdf", True
    Dim db As DAO.Database
    Dim MailList As DAO.Recordset
    Dim MyOutlook As Outlook.Application
    Dim MyMail As Outlook.MailItem
    Dim Subjectline As String
    Dim BodyFile As String
    Dim MyBody As String
    Dim MyBodyText As String
    Set appOutLook = CreateObject("Outlook.Application")
    Set MailOutLook = appOutLook.CreateItem(olMailItem)
    With MailOutLook
    Subjectline$ = "Proposal Attached"
    Set db = CurrentDb()
    'Set MyMail = MyOutlook.CreateItem(olMailItem)
    
    .To = Forms!currentjobs!GCTABLE1!Email
    .Subject = Subjectline$
    
               
                '.BodyFormat = olFormatRichText
                '.BCC = MailList("emailaddress")
                .Subject = Subjectline$
             
                .HTMLBody = Forms!currentjobs!GCTABLE1!gc1name & ":" & _
            vbNewLine & vbNewLine & _
            "UAC Proposal is attached." & _
            vbNewLine & vbNewLine
                  '.Attachments.Add ("([Forms]![currentjobs]![fullpath] & Forms!currentjobs!GCTABLE1.Form.[reportname]")
                    .Attachments.Add MyPath
                    
                    
                'End If
                '.DeleteAfterSubmit = True   'This would let Outlook send th note without storing it in your sent bin
                '.Send
                .Display
                
                End With
    'MailList.MoveNext
    'Loop
    
    Set MyMail = Nothing
    
    'MyOutlook.Quit
    Set MyOutlook = Nothing
    'MailList.Close
    'Set MailList = Nothing
    db.Close
    Set db = Nothing

  5. #5
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Excellent Gina! If resolved, do you want to mark this thread as Solved?

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Emailing example
    By pkstormy in forum Code Repository
    Replies: 4
    Last Post: 01-31-2014, 04:22 PM
  2. Emailing one Record
    By GGCR in forum Import/Export Data
    Replies: 6
    Last Post: 01-20-2014, 09:06 AM
  3. Emailing Just ONE Record
    By HLTAYLOR in forum Misc
    Replies: 8
    Last Post: 06-26-2013, 12:34 PM
  4. Emailing using ACCESS
    By Maxton in forum Access
    Replies: 1
    Last Post: 11-01-2012, 02:53 PM
  5. Emailing
    By fastebs in forum Access
    Replies: 2
    Last Post: 04-13-2012, 12:37 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums