Re: Email Multiple Attachments

Discussion in 'Microsoft Access Forms' started by Sandra Daigle, Dec 11, 2003.

  1. Not using sendobject - just one of the many limitations of sendobject
    (others are found here: http://www.granite.ab.ca/access/sendobject.htm).

    For other methods of sending email check these links:

    http://www.granite.ab.ca/access/email.htm

    Q161088 Using Automation to Send a Microsoft Outlook Message
    http://support.microsoft.com/default.aspx?scid=kb;en-us;Q161088

    HOW TO: Use Automation to Send a Microsoft Outlook Message using Access 2000
    http://support.microsoft.com/default.aspx?scid=kb;en-us;Q209948

    Here's a slightly modified version of the code from the last article which
    shows how to add more than one attachment:

    Sub SendMessage(DisplayMsg As Boolean, Optional AttachmentPath1 As String,
    Optional attachmentpath2 As String)
    Dim objOutlook As Outlook.Application
    Dim objOutlookMsg As Outlook.MailItem
    Dim objOutlookRecip As Outlook.Recipient
    ' Create the Outlook session.
    Set objOutlook = CreateObject("Outlook.Application")

    ' Create the message.
    Set objOutlookMsg = objOutlook.CreateItem(olMailItem)

    With objOutlookMsg
    ' Add the To recipient(s) to the message.
    Set objOutlookRecip = .Recipients.Add("")
    objOutlookRecip.Type = olTo

    ' Add the CC recipient(s) to the message.
    Set objOutlookRecip = .Recipients.Add("")
    objOutlookRecip.Type = olCC

    ' Add the BCC recipient(s) to the message.
    Set objOutlookRecip = .Recipients.Add("Sandra Daigle")
    objOutlookRecip.Type = olBCC

    ' Set the Subject, Body, and Importance of the message.
    .Subject = "This is an Automation test with Microsoft Outlook"
    .Body = "This is the body of the message." & vbCrLf & vbCrLf
    .Importance = olImportanceHigh 'High importance
    ' Add attachments to the message.
    If Not IsMissing(AttachmentPath1) Then
    .Attachments.Add AttachmentPath1
    End If
    If Not IsMissing(attachmentpath2) Then
    .Attachments.Add attachmentpath2
    End If
    ' Resolve each Recipient's name.
    For Each objOutlookRecip In .Recipients
    objOutlookRecip.Resolve
    Next
    End With
    Set objOutlook = Nothing
    End Sub



    --
    Sandra Daigle
    [Microsoft Access MVP]
    For the benefit of others please post all replies to this newsgroup.


    D Collins wrote:
    > I have a button on a form that uses the Send Object
    > command to send a report as a snapshot. Is it possible
    > to send more than one attachment in the same email via
    > code?
    >
    > Thanks.
     
    Sandra Daigle, Dec 11, 2003
    #1
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kevin

    Attachments via email

    Kevin, Aug 28, 2003, in forum: Microsoft Access Forms
    Replies:
    1
    Views:
    163
    Stefan Buijs
    Aug 29, 2003
  2. Mega1

    Email Multiple Reports on one Email

    Mega1, Mar 2, 2005, in forum: Microsoft Access Forms
    Replies:
    1
    Views:
    177
    Sandra Daigle
    Mar 4, 2005
  3. Guest
    Replies:
    0
    Views:
    700
    Guest
    Aug 10, 2005
  4. Matthew Tiojanco

    Possible to rename email attachments?

    Matthew Tiojanco, Jun 13, 2007, in forum: Microsoft Access Forms
    Replies:
    1
    Views:
    164
    Matthew Tiojanco
    Jun 13, 2007
  5. Petemeister2k

    Record count incorrect when a record has multiple attachments

    Petemeister2k, Sep 9, 2009, in forum: Microsoft Access Forms
    Replies:
    3
    Views:
    888
    Clifford Bass
    Sep 10, 2009
Loading...

Share This Page