How to CC a person on an email with VBA code

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • robtech4
    New Member
    • Jul 2012
    • 33

    How to CC a person on an email with VBA code

    I have this code, curtisy of Twinnyfo but I am looking to add another recipient email address as a "cc". Can you please advise on the addition to the code...

    Code:
    Private Sub cmdSubmit_Click() 
    On Error GoTo EH 
        Dim strSubject As String 
        Dim strAddressees As String 
        Dim strEMailBody As String 
        strSubject = "Changes Requested" 
        strAddressees = "your.name@company.com" 
        strEMailBody = "Test Message" 
        DoCmd.SendObject acSendNoObject, , acFormatTXT, strAddressees, , , strSubject, strEMailBody, True 
        Exit Sub 
    EH: 
        MsgBox "There was an error sending this note!  Please contact your Database Administrator.", vbCritical, "Error!" 
        Exit Sub 
    End Sub
  • twinnyfo
    Recognized Expert Moderator Specialist
    • Nov 2011
    • 3662

    #2
    Rob, the CC is the argument after the strAddressees. Just set a variable as strCC or something similar or just add the e-mail ddress...

    Comment

    • robtech4
      New Member
      • Jul 2012
      • 33

      #3
      Code:
      On Error GoTo EH
          Dim strSubject As String
          Dim strAddressees As String
          [B]Dim strCC As String[/B]    
          Dim strEMailBody As String
          strSubject = "Changes Requested"
          strAddressees = "yourname@company.com"
          [B]strCC = "yourname@company.com"[/B]    strEMailBody = "Please look at changes. Thank you."
          DoCmd.SendObject acSendNoObject, , acFormatTXT, strAddressees, , , strSubject, strEMailBody, True
          Exit Sub
      EH:
          MsgBox "There was an error sending this note!  Please contact your Database Administrator.", vbCritical, "Error!"
          Exit Sub
      End Sub

      Like so?

      Comment

      • twinnyfo
        Recognized Expert Moderator Specialist
        • Nov 2011
        • 3662

        #4
        That should do it... don't forget to include it in your arguments:

        Code:
        DoCmd.SendObject acSendNoObject, , acFormatTXT, strAddressees, strCC, , strSubject, strEMailBody, True
        I'm gonna start coming to you for help, next! :-)

        Comment

        • robtech4
          New Member
          • Jul 2012
          • 33

          #5
          I really hope in some way I will eventually be able to help you or start answering some of the other questions on here!

          Comment

          • twinnyfo
            Recognized Expert Moderator Specialist
            • Nov 2011
            • 3662

            #6
            Also, for a reference for this method, you can brush up on other details concerning it here:

            Comment

            Working...