473,587 Members | 2,447 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to CC a person on an email with VBA code

33 New Member
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
5 3291
twinnyfo
3,653 Recognized Expert Moderator Specialist
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
robtech4
33 New Member
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
3,653 Recognized Expert Moderator Specialist
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
robtech4
33 New Member
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
3,653 Recognized Expert Moderator Specialist
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

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

Similar topics

3
2938
by: rock72 | last post by:
Hello there, Can anyone tell me how to create a php script that when the user click the Submit button, a message will be sent to friends email add stored in mysql table? I created this ff table structure using mysql ? Field Type Size Description
0
1432
by: Tony Williams | last post by:
I have a tick box control that when checked opens Outlook and attaches a report. If the user clicks send then everything is OK. BUT if the user clicks the close on Outlook without sending the email I want to trap the error message 2501 and ask the user what to do. Here is my code so far: Private Sub Loadtxt_Click() On Error GoTo Exit_Handler If Me!Loadtxt = True Then DoCmd.SendObject acSendReport, "rptOnlineUpload", acFormatRTF, , , ,...
1
2180
by: Robert V. Hanson | last post by:
Please give me some ideas on how to setup the ability to test System.Web.Mail code to send emails using just my development computer, Win2000Pro OS and IIS5.0? Thanks, Bob Hanson
5
2270
by: | last post by:
Trying to learn about manipulating collections of objects, and populating these objects dynamically from datasources. Could someone post a code sample that shows the following: Instantiating a collection object -- say, a dictionary. Populating that collection object with custom objects, say, Person. What I really want to see is how to populate the properties of those Person objects from a datasource: instantiate one Person, fill...
1
1924
by: Liam.M | last post by:
I currently HAVE a form...a "Summary List" it could be called...which is a contineous form...AND on this form are "Four fields" from EVERY record (each on their own line) so to seak...like a running summary of ALL the Records in the Database! NOW upon clicking "one" of these lines...it then opens that specific Record in the Database...which is linked through and by a "Record ID"! The "four fields" that are exhibited in this contineous...
10
2179
by: Walshi | last post by:
Hi all, I'm a relative newby to access and VBA etc. My forms and tables etc are working great and saving lots of time...However... I have two databases with the exact same table format. I want db1 to be used to input data by a remote operator, when she is ready I want her to be able to click a control button to email her new data to db2. This new data will be added to the table in db2 ready for further processing.
1
2034
by: xian2 | last post by:
Hi All, I have been using this guide http://www.compasscomputing.co.uk/code/AcceesReportsToPDFandEmail.htm to create a command button that automatically saves and e-mails your report and have tried to edit the code, as below (the original code is on his website) but get a load of error messages. There are only a few bits that need editing (about 6 or 7 little bits) but I still get loads of error messages and if anyone can help, I would...
2
1196
by: DrNoose | last post by:
Hi! I'm working on code for a feedback form. I want the data from the user that is taken from the form to be emailed back to me. I'm using vb with visual studios 2005. I have most of the code, but have some missing stuff, because I'm not totally sure what I'm doing! Can someone take a look at this code and tell me what I'm missing.
0
1292
by: .spider | last post by:
Hi, I have a code here (taken from http://www.dotnetwatch.com/page294.aspx). Now i didn't think there was anything wrong with this code(no compilation errors..nothing)..and infact when i ran this code in visual web developer in the debug mode, the code DID mail to the recipient email id. However, after uploading the codes to my hosting account, upon submiting the form(which sends contents of 'TextBox1' and 'TextBox3' to rcv@domain.com), a...
1
1088
by: aquils | last post by:
I have a program which has 4 layers, the PL, Webservice, BL and DL. I have a form which sents an email, any suggestions where should I write the code for sending emails. Thanks
0
7854
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8219
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8221
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6629
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5395
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3882
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2364
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1455
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1192
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.