two files by SendObject

bhelmy

Registered User.
Local time
Today, 04:00
Joined
Dec 6, 2015
Messages
62
I want to attach Query as a excel file and a report as a pdf file in one mail when click Command bottom in form .
I successes to attach on file by code

DoCmd.SendObject acReport, "Query11", "PDFFormat(*.pdf)", "bhelmy@G.com", "", "", "", "", True, ""

Please help me .
thx
 
you should use Outlook automation.
 
i dont want to sent it auto i want to open it with outlook and i will sent after review

thx
 
you should use TransferSpreadsheet to export to excel.
save the report to pdf.
on outlook part:

CreateEmailWithOutlook EmailAddress, CCEmailAddress, Subject, Message, Array(yourExportedExcelFilePath and Name, yourReportName)

Code:
Public Function CreateEmailWithOutlook( _
    MessageTo As String, _
    MessageCC As String, _
    Subject As String, _
    MessageBody As String, _
    AttachmentFile As Variant)

    ' Define app variable and get Outlook using the "New" keyword
    Dim olApp As New Outlook.Application
    Dim olMailItm As Outlook.MailItem  ' An Outlook Mail item
    Dim olFolder As Outlook.Folder
    Dim olNameSpace As Outlook.NameSpace
 
    Dim varItem As Variant

    Set olApp = New Outlook.Application
    Set olNameSpace = olApp.GetNamespace("MAPI")
    Set olFolder = olNameSpace.GetDefaultFolder(olFolderInbox)
    ' Create a new email object
    Set olMailItm = olFolder.Items.Add(olMailItem)

    ' Add the To/Subject/Body to the message and display the message
    With olMailItm
        .To = MessageTo
        .CC = MessageCC
        .Subject = Subject
        .Body = MessageBody
        ' request a readers reciept so I know the email has been read
        .ReadReceiptRequested = True
        If IsArray(AttachmentFile) Then
            For Each varItem In AttachmentFile
                .Attachments.Add varItem
            Next
        Else
            .Attachments.Add AttachmentFile
        End If
        .Display    ' To show the email message to the user
         '.Send
    End With

    ' Release all object variables
    Set olMailItm = Nothing
    Set olFolder = Nothing
    Set olNameSpace = Nothing
    Set olApp = Nothing

End
 
sorry i can't catch the idea
can y help me with Sample --

in form ( Form1) need buttom to open mail with 2 attached ( Query1w ) as Excel and( Qurty1 ) as pdf


so sory i am new vb user
 

Attachments

Error

Please Help
 

Attachments

  • Capture.jpg
    Capture.jpg
    46.7 KB · Views: 138
as ive said you must set reference to Microsoft Outlook Object.
goto Visual Basic Editor. press Alt-F11. on menu, Insert->Reference, find Microsoft Outlook XX.X Object.
 
Thx again
I need I help more if this issue solve I will finish my project .
1- I have a ( Query1 ) I need to export it as a txt file tab delimited with a header of Query .
2- I have a ( Query2 ) I need to export it as a txt file tab delimited with a header of Query and space row before header .

thx
 

Attachments

  • 1.txt
    1.txt
    610 bytes · Views: 67
  • 2.txt
    2.txt
    612 bytes · Views: 68

Users who are viewing this thread

Back
Top Bottom