0
votes

I have a classic asp project. On this project I need to send mail. I need helping hand to send mail from classical asp by using the bellow .config file information.

  <appSettings>
    <add key="smtpHost" value="smtp.gmail.com" />
    <add key="smtpPort" value="587" />
    <add key="emailTo" value="[email protected]" />
    <add key="emailFrom" value="[email protected]" />
    <add key="smtpUser" value="[email protected]" />
    <add key="smtpUserPassword" value="test.smtp" />
    <add key="emailSubject" value="Email Auto Reorder for callback" />
    <add key="smtpDomain" value="" />
    <add key="ClientSettingsProvider.ServiceUri" value="" />
  </appSettings>

In asp.net I use bellow syntax to send mail

System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();
message.To.Add("[email protected]");
message.Subject = "This is the Subject line";
message.From = new System.Net.Mail.MailAddress("[email protected]");
message.Body = "This is the message body";
System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("yoursmtphost");
smtp.Send(message);

I'm just getting into classical asp, so forgive me if this is a basic question. I need help to send mail by using the .config file information .

I Just want to be able to send an email from my website to a given email address using my gmail account (smtp server). I have the following code which others have using successfully, but i get error

<%
Set objCDOSYSMail = Server.CreateObject("CDO.Message")
Set objCDOSYSCon = Server.CreateObject ("CDO.Configuration")

''# Authenticate if necessary
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/sendusername") = "[email protected]"
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "mygmailpassword"

''# Outgoing SMTP server configuration
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 1
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60

''# Update the CDOSYS Configuration
Set objCDOSYSMail.Configuration = objCDOSYSCon
objCDOSYSMail.From = "[email protected]" ''# This has to be valid email address on the selected SMTP server
strSubject = "Email test"
strHTML = "This is a test"
objCDOSYSMail.To = "[email protected]"
objCDOSYSMail.Subject = strSubject
objCDOSYSMail.HTMLBody = strHTML
objCDOSYSMail.Send 
%>

enter image description here

This is a discussion on Error: 006~ASP 0177~Server.CreateObject Failed~800401f3 –asp show me the above error . Can any one help please to solve this issue------------------------------------------------------------------------------------------- Without Set objCDOSYSMail = Server.CreateObject("CDO.Message") The asp file was working fine on my os =win7 and win-server-2003 r2.

2
It is irritating to read a question that includes the text "I get an error" but the error itself is not included. You'd think it would be an obvious piece of information to include yet so many questioners miss out this vital info. What error do you actually get and if possible identify the line that throw the error???AnthonyWJones
Sorry AnthonyWJones to irritating you .I am new in classical asp,it's my first time on classical asp,Forget rest of the syntax after add the syntax=Set Mail = CreateObject("CDO.Message") ,page show error .My os=win7 and win-server-2003 r2 ,iis7shamim
Yes but what error is it showing? In IIS manager select you application and open the "Error Pages" feature, cliek "Edit Feature Settings...", from the dialog select "Detailed Errors". Now try to invoke your page, what error do you see in return page?AnthonyWJones
shamim can you please post the error.Pasha Immortals
Pasha lmmortals after configure the error on my iis get http-500 error message,Thanks AnthonyWJones help me to configure error pageshamim

2 Answers

1
votes

Try this:

Set objEmail = Server.CreateObject("CDONTS.NewMail")
objEmail.to = "[email protected]"
objEmail.From = "[email protected]"
objEmail.Subject = "Subject"
objEmail.Body = "Email Body"
objEmail.send
Set objEmail = nothing

Also look here: http://support.jodohost.com/showthread.php?p=73224

UPDATE:

Look here for some asp code from MS. http://msdn.microsoft.com/en-us/library/ms972337.aspx

1
votes

How to send an email from one Gmail account to another one using a batch file or script?

Const schema   = "http://schemas.microsoft.com/cdo/configuration/"
Const cdoBasic = 1
Const cdoSendUsingPort = 2
Dim oMsg, oConf

' E-mail properties
Set oMsg      = CreateObject("CDO.Message")
oMsg.From     = "[email protected]"  ' or "Sender Name <[email protected]>"
oMsg.To       = "[email protected]"    ' or "Recipient Name <[email protected]>"
oMsg.Subject  = "Subject"
oMsg.TextBody = "Text body"

' GMail SMTP server configuration and authentication info
Set oConf = oMsg.Configuration
oConf.Fields(schema & "smtpserver")       = "smtp.gmail.com"
oConf.Fields(schema & "smtpserverport")   = 465
oConf.Fields(schema & "sendusing")        = cdoSendUsingPort
oConf.Fields(schema & "smtpauthenticate") = cdoBasic
oConf.Fields(schema & "smtpusessl")       = True
oConf.Fields(schema & "sendusername")     = "[email protected]"
oConf.Fields(schema & "sendpassword")     = "sender_password"
oConf.Fields.Update

oMsg.Send