okpnz1
یک شنبه 22 تیر 1393, 11:55 صبح
سلام
من کد ارسال ایمیل رو نوشتم ولی با زدن باتن هیچ عملی انجام نمیشه
اگه کسی میتونه کمکم کنه
if(Page.IsValid)
{
try
{
string strBody = string.Empty;
strBody += string.Format("<b>Full name </b>: {0} <br />", Txt_user.Text );
strBody += string.Format("<b>E-Mail </b>: <a href='mailto:{0}'> {0} </a> <br />", txt_Email.Text );
strBody += string.Format("<b>Time </b>: {0} <br />", txt_tahvil.Text );
strBody += string.Format("<b>Description </b>: {0} <br />", txt_text.Text.Replace("\n" , "<br />") );
System.Net.Mail.MailMessage oMailMessage =
new System.Net.Mail.MailMessage();
System.Net.Mail.MailAddress oMailaddress = null;
oMailaddress=
new System.Net.Mail.MailAddress
(
"oojaghlou.k@gmail.com",
"Auto Response Email Sender",
System.Text.Encoding.UTF8
);
oMailMessage.From = oMailaddress;
oMailMessage.Sender = oMailaddress;
oMailMessage.To.Clear();
oMailMessage.CC.Clear();
oMailMessage.Bcc.Clear();
oMailMessage.ReplyToList.Clear();
oMailMessage.Attachments.Clear();
//میتونیم شخص دیگری را به غیر از خودمان مشخص کنیم که ایمیل را دریافت کند مثل خود شخص
//oMailMessage.ReplyToList.Add(oMailaddress);
//oMailaddress =
// new System.Net.Mail.MailAddress
// (
// txt_Email.Text,
// Txt_user.Text,
// System.Text.Encoding.UTF8
// );
// oMailMessage.To.Add(oMailaddress);
oMailMessage.BodyEncoding = System.Text.Encoding.UTF8;
oMailMessage.Body = strBody;
oMailMessage.SubjectEncoding = System.Text.Encoding.UTF8;
oMailMessage.Subject =
"[-<Type star>-] - " + txt_tel.Text;
oMailMessage.IsBodyHtml=true;
oMailMessage.Priority =
System.Net.Mail.MailPriority.Normal;
oMailMessage.DeliveryNotificationOptions =
System.Net.Mail.DeliveryNotificationOptions.OnSucc ess;
string strRootRelativePathName = "~/img/";
string strPathName =
Server.MapPath(strRootRelativePathName);
if(System.IO.File.Exists(strPathName))
{
System.Net.Mail.Attachment oAttachment =
new System.Net.Mail.Attachment(strPathName);
oMailMessage.Attachments.Add(oAttachment);
}
System.Net.Mail.SmtpClient oSmtpClient =
new System.Net.Mail.SmtpClient();
oSmtpClient.Timeout = 100000;
// agar az gmail estefade mikoni true
oSmtpClient.EnableSsl = true;
oSmtpClient.Send(oMailMessage);
string strInformationMessage =
"سفارش شما ارسال شد";
lblresult.Text = strInformationMessage;
lblresult.Text = "ok";
}
catch(Exception ex)
{
lblError.Text = "no" + ex;
}
}
یسری تنظیمات هم در وب کانفیک انجام دادم
<system.net>
<mailSettings>
<smtp deliveryMethod="Network" from="oojaghlou.k@gmail.com">
<!--porte host 25 gmail ba ssl 465 bi ssl 587 hotmail ba ssl 25 bi ssl 587 yahoo 465-->
<network
defaultCredentials="false"
port="465"
host="smtp.gmail.com"
password="00000000"
userName="oojaghlou.k@gmail.com"
/>
</smtp>
</mailSettings>
</system.net>
من کد ارسال ایمیل رو نوشتم ولی با زدن باتن هیچ عملی انجام نمیشه
اگه کسی میتونه کمکم کنه
if(Page.IsValid)
{
try
{
string strBody = string.Empty;
strBody += string.Format("<b>Full name </b>: {0} <br />", Txt_user.Text );
strBody += string.Format("<b>E-Mail </b>: <a href='mailto:{0}'> {0} </a> <br />", txt_Email.Text );
strBody += string.Format("<b>Time </b>: {0} <br />", txt_tahvil.Text );
strBody += string.Format("<b>Description </b>: {0} <br />", txt_text.Text.Replace("\n" , "<br />") );
System.Net.Mail.MailMessage oMailMessage =
new System.Net.Mail.MailMessage();
System.Net.Mail.MailAddress oMailaddress = null;
oMailaddress=
new System.Net.Mail.MailAddress
(
"oojaghlou.k@gmail.com",
"Auto Response Email Sender",
System.Text.Encoding.UTF8
);
oMailMessage.From = oMailaddress;
oMailMessage.Sender = oMailaddress;
oMailMessage.To.Clear();
oMailMessage.CC.Clear();
oMailMessage.Bcc.Clear();
oMailMessage.ReplyToList.Clear();
oMailMessage.Attachments.Clear();
//میتونیم شخص دیگری را به غیر از خودمان مشخص کنیم که ایمیل را دریافت کند مثل خود شخص
//oMailMessage.ReplyToList.Add(oMailaddress);
//oMailaddress =
// new System.Net.Mail.MailAddress
// (
// txt_Email.Text,
// Txt_user.Text,
// System.Text.Encoding.UTF8
// );
// oMailMessage.To.Add(oMailaddress);
oMailMessage.BodyEncoding = System.Text.Encoding.UTF8;
oMailMessage.Body = strBody;
oMailMessage.SubjectEncoding = System.Text.Encoding.UTF8;
oMailMessage.Subject =
"[-<Type star>-] - " + txt_tel.Text;
oMailMessage.IsBodyHtml=true;
oMailMessage.Priority =
System.Net.Mail.MailPriority.Normal;
oMailMessage.DeliveryNotificationOptions =
System.Net.Mail.DeliveryNotificationOptions.OnSucc ess;
string strRootRelativePathName = "~/img/";
string strPathName =
Server.MapPath(strRootRelativePathName);
if(System.IO.File.Exists(strPathName))
{
System.Net.Mail.Attachment oAttachment =
new System.Net.Mail.Attachment(strPathName);
oMailMessage.Attachments.Add(oAttachment);
}
System.Net.Mail.SmtpClient oSmtpClient =
new System.Net.Mail.SmtpClient();
oSmtpClient.Timeout = 100000;
// agar az gmail estefade mikoni true
oSmtpClient.EnableSsl = true;
oSmtpClient.Send(oMailMessage);
string strInformationMessage =
"سفارش شما ارسال شد";
lblresult.Text = strInformationMessage;
lblresult.Text = "ok";
}
catch(Exception ex)
{
lblError.Text = "no" + ex;
}
}
یسری تنظیمات هم در وب کانفیک انجام دادم
<system.net>
<mailSettings>
<smtp deliveryMethod="Network" from="oojaghlou.k@gmail.com">
<!--porte host 25 gmail ba ssl 465 bi ssl 587 hotmail ba ssl 25 bi ssl 587 yahoo 465-->
<network
defaultCredentials="false"
port="465"
host="smtp.gmail.com"
password="00000000"
userName="oojaghlou.k@gmail.com"
/>
</smtp>
</mailSettings>
</system.net>