By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,471 Members | 2,192 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,471 IT Pros & Developers. It's quick & easy.

How to CC a person on an email with VBA code

P: 33
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...

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdSubmit_Click() 
  2. On Error GoTo EH 
  3.     Dim strSubject As String 
  4.     Dim strAddressees As String 
  5.     Dim strEMailBody As String 
  6.     strSubject = "Changes Requested" 
  7.     strAddressees = "your.name@company.com" 
  8.     strEMailBody = "Test Message" 
  9.     DoCmd.SendObject acSendNoObject, , acFormatTXT, strAddressees, , , strSubject, strEMailBody, True 
  10.     Exit Sub 
  11. EH: 
  12.     MsgBox "There was an error sending this note!  Please contact your Database Administrator.", vbCritical, "Error!" 
  13.     Exit Sub 
  14. End Sub 
  15.  
Aug 9 '12 #1

✓ answered by twinnyfo

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

Expand|Select|Wrap|Line Numbers
  1. DoCmd.SendObject acSendNoObject, , acFormatTXT, strAddressees, strCC, , strSubject, strEMailBody, True
  2.  
I'm gonna start coming to you for help, next! :-)

Share this Question
Share on Google+
5 Replies


twinnyfo
Expert Mod 2.5K+
P: 3,037
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...
Aug 9 '12 #2

P: 33
Expand|Select|Wrap|Line Numbers
  1. On Error GoTo EH
  2.     Dim strSubject As String
  3.     Dim strAddressees As String
  4.     Dim strCC As String    
  5.     Dim strEMailBody As String
  6.     strSubject = "Changes Requested"
  7.     strAddressees = "yourname@company.com"
  8.     strCC = "yourname@company.com"    strEMailBody = "Please look at changes. Thank you."
  9.     DoCmd.SendObject acSendNoObject, , acFormatTXT, strAddressees, , , strSubject, strEMailBody, True
  10.     Exit Sub
  11. EH:
  12.     MsgBox "There was an error sending this note!  Please contact your Database Administrator.", vbCritical, "Error!"
  13.     Exit Sub
  14. End Sub

Like so?
Aug 9 '12 #3

twinnyfo
Expert Mod 2.5K+
P: 3,037
That should do it... don't forget to include it in your arguments:

Expand|Select|Wrap|Line Numbers
  1. DoCmd.SendObject acSendNoObject, , acFormatTXT, strAddressees, strCC, , strSubject, strEMailBody, True
  2.  
I'm gonna start coming to you for help, next! :-)
Aug 9 '12 #4

P: 33
I really hope in some way I will eventually be able to help you or start answering some of the other questions on here!
Aug 9 '12 #5

twinnyfo
Expert Mod 2.5K+
P: 3,037
Also, for a reference for this method, you can brush up on other details concerning it here:

http://msdn.microsoft.com/en-us/libr...ffice.12).aspx
Aug 10 '12 #6

Post your reply

Sign in to post your reply or Sign up for a free account.