Results 1 to 3 of 3
  1. #1
    Skhaliq is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2015
    Posts
    7

    Send Multiple Attachmen in one Email

    Hi, Below code is working good, but want to add one more code like



    DoCmd.SendObject acSendTable, "SM_Main_Output", acFormatXLS, rs("Email Address"), rs("CC"), "", "SM Sales & Availability Report for " & rs("SM"), "Dear Sales Manager, Please find attached Sales and Availability Report. If you have any query regarding your Structure/Area Please contact your Sales coordination department", 0, False


    Please help me on this. I want to send backup data as well.







    Private Sub Command9_Click()
    Dim db As DAO.Database
    Dim rs As DAO.Recordset
    Dim eml As String
    Dim vOfficeID As String
    Set db = CurrentDb
    Set rs = db.OpenRecordset("SM_Email_List", dbOpenDynaset)
    rs.MoveFirst
    Do
    vSMID = rs("SM")
    DoCmd.SetWarnings False
    DoCmd.RunSQL "SELECT [SM_Main_Table].* INTO [SM_Main_Output] FROM [SM_Main_Table] WHERE ((([SM_Main_Table].SM)= '" & vSMID & "'))", -1
    DoCmd.SendObject acSendReport, "SM_SALES_REPORT", acFormatPDF, rs("Email Address"), rs("CC"), "", "SM Sales & Availability Report for " & rs("SM"), "Dear Sales Manager, Please find attached Sales and Availability Report. If you have any query regarding your Structure/Area Please contact your Sales coordination department", 0, False

    rs.MoveNext


    Loop Until rs.EOF
    rs.Close
    db.Close
    End Sub

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    SELECT INTO will create a new table. Why would you create a new table every time this procedure runs?

    What do you mean by 'send backup data'? Exactly what constitutes 'backup data'?

    Cannot use SendObject to send multiple attachments with same email. Review
    https://www.accessforums.net/import-...ail-53783.html
    https://www.accessforums.net/access/...ect-17713.html
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Gina Maylone is offline Always learning
    Windows 7 64bit Access 2013
    Join Date
    Jun 2013
    Location
    Afton, MN
    Posts
    544
    I use this to send multiple documents. Hopefully you can use it along with your code:

    Code:
    Dim stDocName As String
    Dim MyPath As String
    MyPath = "C:\yourdirectory\yoursubfolder\" & Me.reportname ‘(generated by a calculated control on contact form)
    stDocName = "ConfirmationReport"
    DoCmd.OutputTo acReport, stDocName, acFormatPDF, MyPath, True
     
    Dim db As DAO.Database
    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$ = "Your Subject Line"
    Set db = CurrentDb()
     
    .To = Forms![contacts form]!EmailAddress
    .SentOnBehalfOfName = someone@somewhere.com ‘optional
     
    If Me.EmailAddress2 <> "" Then ‘if there’s a second email address
    .BCC = Forms![contacts form]!EmailAddress2
    End If
     
    .Subject = Subjectline$
     
    .Attachments.Add ("c:\yourdirectory\yoursubfolder \YourDocument1.pdf")
    .Attachments.Add ("c:\yourdirectory\yoursubfolder \ YourDocument2.pdf")
    .Attachments.Add ("c:\yourdirectory\yoursubfolder \ YourDocument3.pdf")
    .Attachments.Add MyPath
    '("c:\ yourdirectory\yoursubfolder \" & Forms![contact form]!reportname)
     
    .Display ‘view first before sending, change to .Send to just send it
    End With

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

Similar Threads

  1. Send Multiple report in one email
    By Kmahraz in forum Programming
    Replies: 9
    Last Post: 08-20-2015, 12:56 PM
  2. Send Multiple csv attachments by email
    By shaunacol in forum Import/Export Data
    Replies: 16
    Last Post: 07-20-2015, 12:22 PM
  3. Send email to multiple recipients based on query
    By nablmm in forum Programming
    Replies: 3
    Last Post: 09-11-2014, 05:36 PM
  4. Replies: 5
    Last Post: 05-07-2014, 09:25 AM
  5. send multiple email...code having problem.
    By wnicole in forum Access
    Replies: 15
    Last Post: 10-17-2013, 11:52 PM

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