CDO, ASP and Email Form Problems

  • Thread starter Steve Audus, Chaucer BEC, Sheffield UK
  • Start date
S

Steve Audus, Chaucer BEC, Sheffield UK

How do I alter the follow asp code so the from field produces the a friendly
address
"Name <[email protected]>"

Code is presently used.

<%
If Request.Form("btnSend").Count > 0 Then
Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = Request.Form("subject")
objMessage.Sender = Request.Form("From")
objMessage.To = Request.Form("To")
objMessage.TextBody = Request.Form("message")
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") =
"mailserver"
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objMessage.Configuration.Fields.Update
objMessage.Send
Response.Redirect("../thanks.htm")
End If
%>

<form action="contact.asp" method="post" name="sendEmail" class="content">
<input type="hidden" name="subject" value="Enquiry from Web Site">
<input type="hidden" name="to"
value="(e-mail address removed)"/>
<table align="center" cellpadding="5" bordercolor="#000000"
class="content">
<tr>
<td>Your Email Address</td>
<td><input name="From" type="text" class="content" size="53"
/></td>
</tr>
<tr>
<td valign="top"><div align="right">Your Message</div></td>
<td><textarea name="message" cols="50" rows="6"
wrap="VIRTUAL" class="content"></textarea>
</td>
</tr>
<tr>
<td colspan="2"><div align="center">
<input name="Send" type="submit" />
</div></td>
</tr>
</table>
<div align="center"></div>
<div align="center"></div>
</form>

Thank you any help.

Steve
 
T

ThatsIT.net.au

I don't think you can, I think its your email program that stores that info.
If you have this address in your contacts, it will use the friendly name.



"Steve Audus, Chaucer BEC, Sheffield UK"
 
A

Anthony Jones

<Steve Audus>; <Chaucer BEC>; "Sheffield UK"
How do I alter the follow asp code so the from field produces the a friendly
address
"Name <[email protected]>"

The only thing you could do is add another input for the user to enter their
name.
You can then assignt the From field with:-

..From = Request.Form("name") & "<" & Request.Form("email") & ">"
 
S

Steve Audus, Chaucer BEC, Sheffield UK

That would work, but I am not very experienced with asp.

I tried but the page isn't working now, please advise further.

<%
If Request.Form("btnSend").Count > 0 Then
Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = Request.Form("subject")

objMessage.Sender = Request.Form("From = Request.Form("name") & "<" &
Request.Form("email") & ">")

objMessage.To = Request.Form("To")
objMessage.TextBody = Request.Form("message")
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") =
"mailserver"
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objMessage.Configuration.Fields.Update
objMessage.Send
Response.Redirect("../thanks.htm")
End If
%>

Thank you for any help

Steve
 
A

Anthony Jones

<Steve Audus>; <Chaucer BEC>; "Sheffield UK"
That would work, but I am not very experienced with asp.

I tried but the page isn't working now, please advise further.

<%
If Request.Form("btnSend").Count > 0 Then
Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = Request.Form("subject")

objMessage.Sender = Request.Form("From = Request.Form("name") & "<" &
Request.Form("email") & ">")

objMessage.To = Request.Form("To")
objMessage.TextBody = Request.Form("message")
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") =
"mailserver"
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objMessage.Configuration.Fields.Update
objMessage.Send
Response.Redirect("../thanks.htm")
End If
%>

Thank you for any help


This in your code:-

objMessage.Sender = Request.Form("From = Request.Form("name") & "<" &
Request.Form("email") & ">")

Should be this:-

objMessage.From = Request.Form("name") & "<" & Request.Form("email") & ">"
 
S

Steve Audus, Chaucer BEC, Sheffield UK

Spot on, Thank you Thank You Thank you.

Anthony Jones said:
<Steve Audus>; <Chaucer BEC>; "Sheffield UK"



This in your code:-

objMessage.Sender = Request.Form("From = Request.Form("name") & "<" &
Request.Form("email") & ">")

Should be this:-

objMessage.From = Request.Form("name") & "<" & Request.Form("email") & ">"
 

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

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top