PDA

View Full Version : آموزش: نحوه ی ارسال ایمیل از طریق کد asp.net



mtareh
جمعه 08 اردیبهشت 1391, 17:43 عصر
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 = "mtareh12@gmail.com";
msg.From = "mtarah@mihanmail.ir";
msg.Subject = "Subject";
msg.Body = "Message";
SmtpMail.SmtpServer = smtpServer;
SmtpMail.Send(msg);
}
}
}

merlin425
یک شنبه 10 اردیبهشت 1391, 15:28 عصر
اگه میشه در مورد کدت توضیح هم بده
ممنون