send email part1

Whing Dela Cruz
Whing Dela Cruz used Ask the Experts™
on
Hi experts, how to start coding to develop email to send someone else? I have codes below but I do not know how to do next. Thank you!

<!DOCTYPE html>
<html>
<body>
<h2>Send e-mail</h2>
<form>
Name:<br>
<input type="text" name="name"><br>
E-mail:<br>
<input type="text" name="mail"><br>
Comment:<br>
<input type="text" name="comment" size="50"><br><br>
From:<br>
<input type="text" name="Sender" value="hobbit@yahoo.com"><br>
<input type="submit" value="Send">
<input type="reset" value="Reset">
</form>

</body>
</html>
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Ryan ChongSoftware Team Lead

Commented:
you can try use CDOSYS to do that. it should allow you to configure the SMTP details when necessary.

For more info:

ASP Sending e-mail with CDOSYS
https://www.w3schools.com/asp/asp_send_email.asp

Author

Commented:
Hi experts, I tried to use this code as shown below base on Chong suggested above formula, but found no result at all. I've got not error but when I check the recipient mail, I found nothing. I run this code to server side asp and when I execute it a Response.Write is responding. Am I doing in a right way or this is totally wrong? any guide please. Thank you!
 
<%
Set myMail = CreateObject("CDO.Message")
myMail.Subject = "Sending email with CDO"
myMail.From = "hobbitdelacruz@yahoo.com"
myMail.To = "niwre@yahoo.com"
myMail.TextBody = "This is a message."
myMail.Send
set myMail = nothing
Response.Write "Successfully sent!"
%>
Ryan ChongSoftware Team Lead

Commented:
you may need to configure the SMTP details before you sending the email out.

you can refer to the answer of this question:

https://www.experts-exchange.com/questions/24535297/CDOSYS-Sending-to-Yahoo-Moved-to-Spam-Folder.html

with following yahoo mail settings:

Yahoo SMTP configuration
http://www.serversmtp.com/en/smtp-yahoo
Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Author

Commented:
Hi experts, I can able to run the code as shown below after fixing smtp. However, my recipient still can't receive the email after sending it base on the code below. The code has no error. What should I do next?

<%
Set myMail = CreateObject("CDO.Message")
myMail.Subject = "Sending email with CDO"
myMail.From = "hobbitdelacruz@yahoo.com"
myMail.To = "niwre@yahoo.com"
myMail.TextBody = "This is a message."
myMail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
'Name or IP of remote SMTP server
myMail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "118.91.12.75"
'Server port
myMail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
myMail.Configuration.Fields.Update
myMail.Send
set myMail = nothing
Response.Write "Successfully sent!"
%>

Author

Commented:
Hello Experts, When I run the code shown above no error appeared, but SMPT error goes directly to Badmail. The specific error code was 0xC00402C7. Is there anyone who can help me which part of my server needs to fix? I am using iis v5.1 and my Default SMPT has already set-up. Thank you!
Ryan ChongSoftware Team Lead

Commented:
so you wish to send out emails via default SMTP setting in IIS OR via a SMTP setting just like your email (your own domain email, yahoo, etc) ?

Author

Commented:
HI Chong, I actually can't differentiate among the two options, but I guest via dafault SMTP setting in IIS is good for me since I have already setting up them on my server pc.
Software Team Lead
Commented:
check this article, especially in the section: Configure SMTP E-Mail for a Web Application

Configure SMTP E-Mail in IIS 7
https://www.iis.net/learn/application-frameworks/install-and-configure-php-on-iis/configure-smtp-e-mail-in-iis-7-and-above

Or you can try to configure using custom SMTP setting, like gmail

Email To Gmail Using Access VBA
http://www.blueclaw-db.com/access_email_gmail.htm

i tried this and it works for me (example using Gmail) :

<%

send = true
msg = ""

if request.form <> "" then
    if request("name") = "" then
        send = false
        msg = msg & "Receiver's name is required<br>"
    end if
    if request("mail") = "" then
        send = false
        msg =  msg & "Receiver's email address is required<br>"
    end if
    if request("comment") = "" then
        send = false
        msg =  msg & "Email's comment is required<br>"
    end if
    if request("Sender") = "" then
        send = false
        msg =  msg & "Sender's email address is required<br>"
    end if
else
    send = false
end if

if send = true then
    
    Set myMail = CreateObject("CDO.Message")
    myMail.Subject = "Sending email with CDO"
    myMail.From = request("Sender")
    myMail.To = request("mail")
    myMail.TextBody = request("comment")

    myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
    myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"
    myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465

    myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
    myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
    myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = "yourGmail@gmail.com"
    myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "yourPassword"

    myMail.Configuration.Fields.Update
    myMail.Send
    set myMail = nothing

    response.write "Email was sent out"
else
    response.write msg
end if

%>

<!DOCTYPE html>
<html>
<body>
<h2>Send e-mail</h2>
<form method="post">
Name:<br>
<input type="text" name="name" value="<%=Server.HTMLEncode(request("name"))%>" /><br>
E-mail:<br>
<input type="text" name="mail" value="<%=Server.HTMLEncode(request("mail"))%>" /><br>
Comment:<br>
<input type="text" name="comment" size="50" value="<%=Server.HTMLEncode(request("comment"))%>" /><br><br>
From:<br>
<input type="text" name="Sender" value="hobbit@yahoo.com"><br>
<input type="submit" value="Send">
<input type="reset" value="Reset">
</form>

</body>
</html> 

Open in new window

Author

Commented:
Thank you so much Chong, It's working. Now, I'm so happy that I can send email. Thanks for providing me such codes. More power and God bless!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial