Email attachments with reports

rainbows

Registered User.
Local time
Today, 10:57
Joined
Apr 21, 2017
Messages
428
Code:
Private Sub cmdEmail_Click()




    Dim strTo As String
    Dim strSubject As String
    Dim strMessageText As String
    
    Me.Dirty = False
     strTo = [Order Details subform].[Form]![EMailaddress]
 
    strSubject = " Acknowledgement Number " & Me.id
    strMessageText = Me.Firstname & "," & _
        vbNewLine & vbNewLine & _
        "Your latest Acknowledgement is attached." & _
        vbNewLine & vbNewLine & _
        ""


    DoCmd.SendObject ObjectType:=acSendReport, _
        ObjectName:="order acknowledgement", _
        OutputFormat:=acFormatPDF, _
        To:=strTo, _
        Subject:=strSubject, _
        messageText:=strMessageText, _
        EditMessage:=True
    

End Sub



This code sends the an e.mail to the customer but i need to send the terms and conditions which is a pdf file with the "order acknowledgement" at this time i have attached the terms and condition file to a table called attachments .

thanks
steve




1675967362358.png
 
Hi Steve,

I think to attach the database attachments into an email, you'll have to extract them first and save them on the hard drive for the email. You can automate this process.
 
hi

I dont need to have it as an attachment I put it there as I thought that was the only way you could attach it to the e.mail thats was sending the order acknowlegement

Steve
 
hi

I dont need to have it as an attachment I put it there as I thought that was the only way you could attach it to the e.mail thats was sending the order acknowlegement

Steve
Ah okay, so if you know the full path to the file you want to attach, you can use Outlook Automation to create the email and attach the files. You won't be able to use SendObject anymore. Are you using MS Outlook for sending/reading emails?
 
Code:
Private Sub cmdEmail_Click()




    Dim strTo As String
    Dim strSubject As String
    Dim strMessageText As String
  
    Me.Dirty = False
     strTo = [Order Details subform].[Form]![EMailaddress]

    strSubject = " Acknowledgement Number " & Me.id
    strMessageText = Me.Firstname & "," & _
        vbNewLine & vbNewLine & _
        "Your latest Acknowledgement is attached." & _
        vbNewLine & vbNewLine & _
        ""


    DoCmd.SendObject ObjectType:=acSendReport, _
        ObjectName:="order acknowledgement", _
        OutputFormat:=acFormatPDF, _
        To:=strTo, _
        Subject:=strSubject, _
        messageText:=strMessageText, _
        EditMessage:=True
  

End Sub



This code sends the an e.mail to the customer but i need to send the terms and conditions which is a pdf file with the "order acknowledgement" at this time i have attached the terms and condition file to a table called attachments .

thanks
steve




View attachment 106331
Well, that is going to bloat your DB quickly? :(
 
Yes, don't save the PDF file in your DB. Save it as a PDF in a sub folder and if necessary save only the name of the PDF in your DB.
 

Users who are viewing this thread

Back
Top Bottom