Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CDONTS Email - send carbon copy to email sender 2

Status
Not open for further replies.

Lupo

Programmer
Oct 29, 2001
31
CH
Hello, i use on my webpage a form, submit by email to my office and my home emailadresse.

This part of the job runs very well. As mentioned at the of the code the sender of the email should receive a carbon copy of the sent email.

This part of the job doesn't work. What or where do I have to modifiy my code?? Or are there any other solutions?

Code:
<%
Response.Buffer = True

'Dimension variables
'Holds the body of the e-mail
Dim strBody

'Holds the subject line of the e-mail
Dim strSubject

'Holds the mail server object
Dim objCDOMail

'Holds my office e-mail address
Dim strMyEmailAddress

'Holds any carbon copy e-mail addresses
Dim strCCEmailAddress

'Holds any blind copy e-mail addresses 
Dim strBCCEmailAddress

'Holds the return e-mail address of the user
Dim strReturnEmailAddress


'-- My e-mail address --
strMyEmailAddress = &quot;MyEmail@office.com&quot; 

'-- Carbon Copy e-mail address, separated by ; --
strCCEmailAddress = &quot;MyEmail@home.com&quot; 

'-- Blind Copy e-mail address, separated by ; --
strBCCEmailAddress = &quot;&quot;

'Read in the users e-mail address
strReturnEmailAddress = Request.Form(&quot;email&quot;)

'Initialse strSubject string with the Subject line of the e-mail
strSubject = strSubject & Request.Form(&quot;subject&quot;)

'Initialse strBody string with the body of the e-mail

strBody = strBody & &quot;<br>E-mailaddress: &quot; & strReturnEmailAddress
strBody = strBody & &quot;<br><br>Message: <br>&quot; & Replace(Request.Form(&quot;enquiry&quot;), vbCrLf, &quot;<br>&quot;)

'Check to see if the user has entered an e-mail address and that it is a valid address otherwise the e-mail will be rejected
If Len(strReturnEmailAddress) < 5 OR NOT Instr(1, strReturnEmailAddress, &quot; &quot;) = 0 OR InStr(1, strReturnEmailAddress, &quot;@&quot;, 1) < 2 OR InStrRev(strReturnEmailAddress, &quot;.&quot;) < InStr(1, strReturnEmailAddress, &quot;@&quot;, 1) Then
	
'Set the return e-mail address to my own
    strReturnEmailAddress = strMyEmailAddress
End If	

'Send the e-mail
'Create the e-mail server object
Set objCDOMail = Server.CreateObject(&quot;CDONTS.NewMail&quot;)

'Who the e-mail is from
objCDOMail.From = Request.Form(&quot;firstName&quot;) & &quot; &quot; & Request.Form(&quot;lastName&quot;) & &quot; <&quot; & strReturnEmailAddress & &quot;>&quot;

'Who the e-mail is sent to
objCDOMail.To = strMyEmailAddress

'Who the carbon copies are sent to
objCDOMail.Cc = strCCEmailAddress

'Who the blind copies are sent to
objCDOMail.Bcc = strBCCEmailAddress

'Set the subject of the e-mail
objCDOMail.Subject = strSubject

'Set the e-mail body format (0=HTML 1=Text)
objCDOMail.BodyFormat = 0

'Set the mail format (0=MIME 1=Text)
objCDOMail.MailFormat = 0

'Set the main body of the e-mail
objCDOMail.Body = strBody

'Importance of the e-mail (0=Low, 1=Normal, 2=High)
objCDOMail.Importance = 1 

'Send the e-mail
objCDOMail.Send
	
'Close the server object
Set objCDOMail = Nothing
%>

<!doctype html public &quot;-//W3C//DTD HTML 4.0 transitional//EN&quot;>
<html>
<head>
</head>
<body>
<!-- Confirmation -->
Your message has been submitted and you will find a copy in your mailbox shortly.
</body>
</html>

Thanks in advance for your help.
Regards and have a nice weekend
Lupo WEB Designer & WEB Developer (as per my working contract) and especially ASP Newbie :)
 
have you tried

objCDOMail.Cc = &quot;MyEmail@home.com&quot;

to see if there's something wrong between setting the variable strCCEmailAddress and using it in the objCDOMail.Cc line?
 
You don't try to copy the sender in your code anywhere - you only put it in the from field. If you want to carbon copy the sender, you need to modify your code to the following:

'Read in the users e-mail address
strReturnEmailAddress = Request.Form(&quot;email&quot;)

'-- Carbon Copy e-mail address, separated by ; --
strCCEmailAddress = &quot;MyEmail@home.com;&quot; & strReturnEmailAddress

If you use this with your current &quot;To&quot; address, then the email will be sent to your work address and copied to your home address and the sender. This will allow the sender to view your two email addresses - do you want that to happen.

Maybe you should think about sending the email to the sender and BCC your two email addresses.




Mise Le Meas,

Mighty :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top