Results 1 to 4 of 4
  1. #1
    swenger is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Mar 2016
    Posts
    151

    Code for adding a CC to an email

    I have this code I have been using for a while which works to create an email with a PDF of a report. However I wanted to add a CC and tried several options found online but none seem to work. I have left them all in the code just for you to see what I tried but I tired them each separately



    Code:
    Private Sub emailTest_Click()
    
    On Error GoTo emailTest_Click_Err
    
    
        Sbj = RMAN & ".pdf"
    
    
        DoCmd.OutputTo acOutputReport, "RAnalysisPDF", acFormatPDF, Sbj, , , , 0
    
    
        Sbj = "Analysis Results for " & RMAN
        fle = RMAN & ".pdf"
    
    
    Dim appOutLook As Outlook.Application
    Dim MailOutLook As Outlook.MailItem
    Dim MailAttachment As Outlook.Attachments
    'Option 1 Dim recipientTo As Outlook.Recipient
    'Option 1 Dim recipientCC As Outlook.Recipient
    
    
        Set appOutLook = CreateObject("Outlook.Application")
        Set MailOutLook = appOutLook.CreateItem(olMailItem)
    
    'Option 1    recipientTo = Recipients.Add("name@domain.com")
    'Option 1    recipientTo.Type = Outlook.OlMailRecipientType.olTo
    'Option 1    recipientCC = Recipients.Add("name@domain.com")
    'option 1    recipientCC.Type = Outlook.OlMailRecipientType.olCC
    
        MailOutLook.Display
        With MailOutLook
            .subject = Sbj
    'Option 2         recipientTo = Recipients.Add("name@domain.com")
    'Option 2         recipientTo.Type = Outlook.OlMailRecipientType.olTo
    'Option 2         recipientCC = Recipients.Add("name@domain.com")
    'Option 2         recipientCC.Type = Outlook.OlMailRecipientType.olCC
           
    'This works        .Recipients.Add ("name@domain.com")
            .Attachments.Add fle
            .Display 'This will display the message for you to check and send yourself
    
    
        End With
        
    emailTest_Click_Exit:
        Exit Sub
    
    
    emailTest_Click_Err:
        MsgBox Error$
        Resume emailTest_Click_Exit
        
    End Sub

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    I have never used Recipients.Add.

    If you have only 1 To address and only 1 CC address, don't need Add method. Just directly set the To and CC.

    .To = "name@domain.com"
    .CC = "name@domain.com"

    Alternative to Add method for addresses is to build a semi-colon separated string of the multiple addresses.
    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
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,524
    .subject = sbj
    .To = "myMain@acme.com"
    .CC = "myCC@acme.com"

  4. #4
    swenger is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Mar 2016
    Posts
    151
    Worked. Thanks so much

    Quote Originally Posted by June7 View Post
    I have never used Recipients.Add.

    If you have only 1 To address and only 1 CC address, don't need Add method. Just directly set the To and CC.

    .To = "name@domain.com"
    .CC = "name@domain.com"

    Alternative to Add method for addresses is to build a semi-colon separated string of the multiple addresses.

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

Similar Threads

  1. Replies: 6
    Last Post: 03-26-2014, 10:04 AM
  2. Updating adding records by using email
    By Andyjones in forum Access
    Replies: 1
    Last Post: 01-29-2013, 07:19 AM
  3. adding signature to the email sendobject
    By webisti in forum Access
    Replies: 3
    Last Post: 07-10-2012, 03:08 PM
  4. Adding a logo to an email that is being sent through Access2010
    By crowegreg in forum Import/Export Data
    Replies: 3
    Last Post: 04-22-2012, 09:28 PM
  5. Adding a email address on form
    By akhlaq768 in forum Forms
    Replies: 3
    Last Post: 02-07-2012, 09:11 AM

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