طریقه ارسال ایمیل در کد ASP

طریقه ارسال ایمیل در کد ASP

برای ارسال ایمیل در کد ASP شما از دو روش CDO  و ASPMail   می توانید استفاده کنید، کد نمونه را میتوانید در اینجا مشاهده کنید:

**********ASP – CDO
On Error Resume Next
Set objEmail = CreateObject(“CDO.Message”)
objEmail.From = “POP3ACCOUNT.NAME”
objEmail.To = “RECIPIENT”
objEmail.Subject = “SUBJECT”
objEmail.Textbody = “BODY”
objEmail.Configuration.Fields.Item (“http://schemas.microsoft.com/cdo/configuration/sendusing”) = 2
objEmail.Configuration.Fields.Item (“http://schemas.microsoft.com/cdo/configuration/smtpserver”) = “MAIL.DOMAIN.COM”
objEmail.Configuration.Fields.Item (“http://schemas.microsoft.com/cdo/configuration/smtpserverport”) = 25
objEmail.Configuration.Fields.Item (“http://schemas.microsoft.com/cdo/configuration/smtpauthenticate”) = “1”
objEmail.Configuration.Fields.Item (“http://schemas.microsoft.com/cdo/configuration/sendusername”) = “POP3ACCOUNT.NAME”
objEmail.Configuration.Fields.Item (“http://schemas.microsoft.com/cdo/configuration/sendpassword”) = “POP3.PASSWORD”
objEmail.Configuration.Fields.Update
objEmail.Send
If Not err.number=0 Then
Response.write “ERROR: ” & err.Description
err.Clear
end if
Set objEmail = Nothing

**********asp – aspEmail
On Error Resume Next
Set Mail = Server.CreateObject(“Persits.MailSender”)
Mail.From = “POP3ACCOUNT.NAME”
Mail.AddAddress “RECIPIENT”
Mail.Subject = “SUBJECT”
Mail.Body = “BODY”
Mail.Host = “MAIL.DOMAIN.COM”
Mail.Username = “POP3ACCOUNT.NAME”
Mail.Password = “POP3.PASSWORD”
Mail.Send
If Not err.number=0 Then
Response.write “ERROR: ” & err.Description
err.Clear
end if
Set Mail = Nothing