نحوه ارسال ایمیل از طریق کد asp.net

using System;
using System.Web.Mail;
namespace SMTPAuthentication
{
public class SMTPAuthenticationExample
{
public static void SendMail()
{
string smtpServer = "mail.yourdomain.com";
string userName = "you@yourdomain.com";
string password = "YourMailboxPassword";
int cdoBasic = 1;
int cdoSendUsingPort = 2;
MailMessage msg = new MailMessage();
if (userName.Length > 0)
{
msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserver", smtpServer);
msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserverport", 25) ;
msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusing", cdoSendUsingPort) ;
msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", cdoBasic);
msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", userName);
msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", password);
}
msg.To = "someone@domain.com";
msg.From = "you@yourdomain.com";
msg.Subject = "Subject";
msg.Body = "Message";
SmtpMail.SmtpServer = smtpServer;
SmtpMail.Send(msg);
}
}
}

Was this answer helpful?

 Print this Article

Also Read

چگونه به کنترل پنل HELM متصل شوم؟

جهت اتصال به کنترل پنل هاست خود باید در یک صفحه Internet Explorer آدرس cp.yourdomain.com را وارد...

روش BackUp/Restore برای پایگاه داده SQL Server 2005.

از تاریخ اول تیر ماه 86 رجیران به تمام مشترکین میزبانی وب ویندوز با کنترل پنل HELM که دارای امکان...

چگونه میتوانم یک برنامه ASP.NET 2 را آپلود کنم ؟

با توجه به اینکه مایکروسافت در ویژوال استودیو 2005 نحوه اجرا و کامپایل برنامه ها را تغییر داده...

در HELM چگونه می توان یک صندوق پستی (Email Address) ایجاد نمود؟

جهت ایجاد یک صندوق پستی (Email Address) مطابق مراحل زیر عمل نمایید:1- وارد کنترل پنل Helm شوید....

نحوه ی نصب و دسترسی Awstats در HELM چگونه است؟

جهت نصب و دسترسی به Awstats بر اساس مراحل زیر پیش بروید: 1- وارد کنترل پنل شوید. 2- بر روی اسم...