How to CC in an email

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,

I have what I hope is a simple request. Below is the code I use to email
from an access form. I can SendTo: someone but I need the piece that lets me
Cc: someone. Any help would be appreciated.
Thanks!

Private Sub Command39_Click()
On Error GoTo EH
Dim SendTo As String, MySubject As String, MyMessage As String
SendTo = "someone's email address"
MySubject = "Additional Information Needed"
MyMessage = Me.LoanNumber & vbCr & Me.CustomerFirst & " " & Me.CustomerLast
& vbCr & Me.ErrorCode & _
vbCr & Me.Comments
DoCmd.SendObject acSendNoObject, , , SendTo, , , MySubject, MyMessage, True

EH:
If Err.Number = 2501 Then
MsgBox "This email message has not been sent. Message has been
cancelled."
End If
End Sub
 
Stockwell43 said:
Hello,

I have what I hope is a simple request. Below is the code I use to email
from an access form. I can SendTo: someone but I need the piece that lets
me
Cc: someone. Any help would be appreciated.
Thanks!

Private Sub Command39_Click()
On Error GoTo EH
Dim SendTo As String, MySubject As String, MyMessage As String
SendTo = "someone's email address"
MySubject = "Additional Information Needed"
MyMessage = Me.LoanNumber & vbCr & Me.CustomerFirst & " " &
Me.CustomerLast
& vbCr & Me.ErrorCode & _
vbCr & Me.Comments
DoCmd.SendObject acSendNoObject, , , SendTo, , , MySubject, MyMessage,
True

EH:
If Err.Number = 2501 Then
MsgBox "This email message has not been sent. Message has been
cancelled."
End If
End Sub

Check Help topics for SendObject. As I recall it goes directly after
SendTo.
DoCmd.SendObject acSendNoObject, , , SendTo,CopyTo , , MySubject, MyMessage,
True
 
Yes, but I did not use the Macro. I use some code that was on this site, but
it did not have the Cc part. Do you happen to know what is?
 
As Bruce mentioned, by looking at the VBE help for SendObject you can see
that the basic synthax is

expression.SendObject(ObjectType, ObjectName, OutputFormat, To, Cc, Bcc,
Subject, MessageText, EditMessage, TemplateFile)

Therefore you need only supply this method with the fifth input variable as
your CC email address.

Private Sub Command39_Click()
On Error GoTo EH
Dim SendTo As String, SendCC As String, MySubject As String, MyMessage As
String
SendTo = "someone's email address"
SendCC = "someone's email address"
MySubject = "Additional Information Needed"
MyMessage = Me.LoanNumber & vbCr & Me.CustomerFirst & " " &
Me.CustomerLast
& vbCr & Me.ErrorCode & _
vbCr & Me.Comments
DoCmd.SendObject acSendNoObject, , , SendTo, SendCC, , MySubject, MyMessage,
True

EH:
If Err.Number = 2501 Then
MsgBox "This email message has not been sent. Message has been
cancelled."
End If
End Sub

--
Hope this helps,

Daniel P
 
The Send To is blank because it can be send to various individuals but the
Send Cc is constant so I wanted that to always prefill when the email pops
up. Does the Send To need to have an email address in it in order for the Cc
field to be filled in?
 
Stockwell,

The function works fine for me. here is a slightly modified version that
works. try it, then start troubleshooting for there.

On Error GoTo EH
Dim SendTo As String, SendCC As String, MySubject As String, MyMessage
As String
SendTo = "someone's email address"
SendCC = "someone's email address"
MySubject = "Subject header"
MyMessage = "Message Body"
DoCmd.SendObject acSendNoObject, , , SendTo, SendCC, , MySubject,
MyMessage, True

EH:
If Err.Number = 2501 Then
MsgBox "This email message has not been sent. Message has been
cancelled."
End If

Also, when you say "none of the other fields fill in", which ones? Subject,
To, body??? you need to give us information if we are to help. Are you
refering to the fields from you form?

What I will suggest it that you use debug.print to check your variable as
you build your routine. test it and see if you variables are getting
populated, from there you can isolate where the problem is originating from.
But the basic code is functional, I tested it! All the fields get filled
(TO, CC, Subject, Body).
--
Hope this helps,

Daniel P
 
Hi Daniel,

I'm not sure what you but it works perfectly! Thank you very much for your
patience and staying with me on this. I will save this and use in the future.

Thank again and have a great day!!!!
 
Back
Top