با سلام و احترام
ضمن تشکر از زحمات شما،نمونه کد زیر تست شده و مشکلی نداره که میتونید در صورت تمایل استفاده نمایید.
منصور عزیزی
SmtpClient mySmtpClient = new SmtpClient("webmail.yourdomain.ir", 25);
mySmtpClient.Credentials = new System.Net.NetworkCredential()
{
UserName = "info@yourdomain.ir",
Password = "12583214A@rf"
};
mySmtpClient.EnableSsl = false;
// add
from,to mailaddresses
MailAddress from = new MailAddress("info@yourdomain.ir.ir",your Co");
MailAddress
to = new MailAddress(Reciver.ExternalReciver.Email);
MailMessage myMail = new System.Net.Mail.MailMessage(from, to);
// add ReplyTo
MailAddress replyto = new MailAddress("info@yourdomain.ir");
myMail.ReplyToList.Add(replyto);
// set subject and encoding
myMail.Subject = "ECE Email";
myMail.SubjectEncoding = System.Text.Encoding.UTF8;
// set body-message and encoding
myMail.Body = "<b>Test
Mail</b><br>using <b>HTML</b>.";
myMail.BodyEncoding = System.Text.Encoding.UTF8;
//
text or html
myMail.IsBodyHtml = true;
if (attachmentFilename != null)
{
Attachment attachment = new Attachment(attachmentFilename, MediaTypeNames.Application.Octet);
ContentDisposition disposition = attachment.ContentDisposition;
disposition.CreationDate = File.GetCreationTime(attachmentFilename);
disposition.ModificationDate = File.GetLastWriteTime(attachmentFilename);
disposition.ReadDate = File.GetLastAccessTime(attachmentFilename);
disposition.FileName = Path.GetFileName(attachmentFilename);
disposition.Size = new FileInfo(attachmentFilename).Length;
disposition.DispositionType = DispositionTypeNames.Attachment;
message.Attachments.Add(attachment);
}
try
{
mySmtpClient.Send(myMail);
return true;
}
catch (Exception
ex)
{
return false;
}