من خلال تلك الشيفرة تسطيع ارسال بريد إلكترونى برمجياً عن طريق بروتوكول نقل البريد الإلكتروني للهوت ميل “HotMail SMTP”.
بيانات السيرفر :
المضيف : smtp.live.com
المنافذ : المفضل لبروتوكول نقل البريد الإلكتروني “SMTP” هو منفذ 587 بدلا من 25 نظرا لأن العديد من مقدمى خدمات الانترنت تستخدم المنفذ 25 لذلك فهو غير متاح او تم حجبة.
خيار SSL : يجب تفعيلة
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | using System; using System.Windows.Forms; using System.Net; using System.Net.Mail; class Script { [STAThread] static public void Main(string[] args) { MailAddress formAddress = new MailAddress("<form>@hotmail.com", "display name"); MailAddress toAddress = new MailAddress("<to>@yahoo.com", "display name"); MailMessage message = new MailMessage(formAddress, toAddress); message.Subject = "eMail test using smtp.live.com"; message.Body = "<b>السلام عليكم</b>, هذه الرساله ارسلت برمجياً بلغة سى شارب عن طريق سيرفر الهوت ميل"; message.IsBodyHtml = true; SmtpClient smtp = new SmtpClient("smtp.live.com", 587); smtp.EnableSsl = true ; smtp.Credentials = new NetworkCredential( /* Your Windows Live ID, for example yourname@hotmail.com */ "username@hotmail.com", /* The password you usually use to sign in to Hotmail or Windows Live */ "*******" ); try { smtp.Send(message); MessageBox.Show("تم ارسال الرسالة بنجاح."); } catch (Exception ex) { MessageBox.Show("الرساله لم ترسل بسبب : " + ex.Message); } } } |
مجهود رائع أخي الكريم
سأقوم بتجربته
تقبل تحياتي
ألف شكر
بس هل اقدر ابعت لاكثر من ايميل ؟؟
يمكن الارسال الى اكثر من بريد من خلال
message.Bcc.Add(“manager1@contoso.com”);
message.Bcc.Add(“manager2@contoso.com”);
message.Bcc.Add(“manager3@contoso.com”);
message.Bcc.Add(“manager4@contoso.com”);