Email problem

S

Stockwell43

Hello,

I am trying to put in 5 five names in the SendCC and it works fine for the
first three but when I drop to the next line to add the other two, I get a
syntax compile error and the last two name appear in red. Could someone
please help me. I'm sure I am not adding something in the code but don't know
what.

Here is the code I am using:

On Error GoTo EH
Dim SendTo As String, SendCC As String, MySubject As String, MyMessage
As String
SendTo = ""
SendCC = "(e-mail address removed),
(e-mail address removed), (e-mail address removed) &_"
(e-mail address removed), (e-mail address removed)"
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

Thanks!!
 
A

Allan Murphy

You are missing a comma , after the third email address just before the &
(e-mail address removed) should be (e-mail address removed),

Allan
 
S

Stockwell43

Hi Allan,

Thank you for responding. It didn't work. It still says Syntax error:
Compile Error. If I place all the name in one row it works fine. However, I
don't want to do that because I would like to know how to move it to the next
line and still have it work in case I have more names to add. Is there
another way or did I leave something else out?

Thanks!!!
 
A

Allan Murphy

Try this
"(e-mail address removed), (e-mail address removed),
(e-mail address removed) " & _
vbcrlf & "(e-mail address removed), (e-mail address removed)"

the vbcrlf is visual basic for Carriage Return Line Feed. Like the old
typewriter days move to the start of the current line then add a linefeed
(new line)

Allan
 
B

Bill

You don't need any "carraige returns" in your string, so

SendCC = "(e-mail address removed), (e-mail address removed), "
_
& "(e-mail address removed), (e-mail address removed),
(e-mail address removed)"

will work just fine. Note that there is a blank between the
quote and the continuation under-score.

I have to ask: Why do you find yourself having to hard-code
e-mail addresses in your code, rather than taking them from
your database as fields?

Bill
 
B

Bill

I see my note didn't format as intended when
posted, as the under-score got placed on a
separate line.

A better demonstration would be:

SendCC = "(e-mail address removed), " _
& "(e-mail address removed), " _
& "(e-mail address removed), " _
& "(e-mail address removed), " _
& "(e-mail address removed)"

Bill
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

BCC Email 3
Email Issue 1
Email issue 0
Bold Code 2
SendObject Email 2
Error on sending email 2
Email Help 17
Emailing with field name in body of email 7

Top