Customer Portal Language
 
Home Knowledge Base HowTo HOWTO: Email solution for ASP, .Net 1.1 and .Net 2.0
Information
Article ID12
Created On5/21/2008
Modified5/21/2008
Share With Others
HOWTO: Email solution for ASP, .Net 1.1 and .Net 2.0

All emails sent from a website form must use SMTP Authentication, otherwise you will receive a "No such user here" error described in the article: https://support.aspnix.com/KB/a7/error-550-no-such-user-here.aspx

These is the sample code you can use for your email forms on websites:


ASP (with Persits)

 Set Mail = Server.CreateObject("Persits.MailSender")
 Mail.Username = "name@mydomain.com
 Mail.Password = "mypassword"
 Mail.Host = "mail.mydomain.com"
 Mail.From = "name@mydomain.com"
 Mail.FromName = "Questionarios Online"
 Mail.AddAddress "recipient_address", "recipient_name"
 Mail.Subject = "My Subject"
 Mail.Body = "BodyText"
 Mail.Send

ASP .Net 1.1

using System.Web.Mail;

SmtpMail.SmtpServer =  "mail.mydomain.com";
mailMsg = new MailMessage();
mailMsg.Fields["http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"] = 1;
mailMsg.Fields["http://schemas.microsoft.com/cdo/configuration/sendusername"] = "name@mydomain.com";
mailMsg.Fields["http://schemas.microsoft.com/cdo/configuration/sendpassword"] = "mypassword";
mailMsg.From = "name@mydomain.com";
mailMsg.To = "recipient_address";
mailMsg.Subject = "My Subject";
mailMsg.Body = "Body text here";
SmtpMail.Send(mailMsg);

ASP .Net 2.0

In web.config file:

 <system.net>
  <mailSettings>
   <smtp from="name@mydomain.com">
    <network host="mail.mydomain.com" userName="name@mydomain.com" password="mypassword"/>
   </smtp>
  </mailSettings>
 </system.net>

ASP (with CDO)

Set CdoConfiguration = CreateObject("CDO.Configuration") 
CdoConfiguration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 
CdoConfiguration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mail.mydomain.com"
CdoConfiguration.Fields.Update  
Set Mail = Server.CreateObject("CDO.Message")
Mail.From = EMAIL_ADDRESS_SENDER
Mail.To = mstrEmailAddressParent
Mail.Subject = strSubject
Mail.HTMLBody = strBody
Mail.Send
set Mail = nothing
set CdoConfiguration = nothing


Source:
http://community.aspnix.com/t/2496.aspx