About

Mohammad Elsheimy

Mohammad Elsheimy is Microsoft developer, trainer, and technical writer works for no one but himself.

Mohammad is a MCP, MCTS, and MCPD expertized in .NET Framework technologies. He is currently a student in Faculty of Holy Quranic Sciences (Azhar University.)

Mohammad was born in 1991 in Banha, Egypt. He is so proud of being Egyptian and he loves Egypt more than anything else (except his code, actually!)

Currently, he runs 3 blogs:

In his spare time, Mohammad enjoys surfing the Web, facebooking, twittering, and playing card games.

You can reach Mohammad at elsheimy[at]live[dot]com

  • Al salamo alykom,
    Hi Mohammed how are you,
    Great to have a target to achieve, great to insist on, but not great to make your target to be another Microsoft fan!!

    I don’t hate Microsoft, or love it, But Technology != Microsoft any way.

    Try to look outside Microsoft’s circle, there is yet another world.
    What i get annoyed from some of friends who are MS fans that, they don’t see more or less than Microsoft. but again, there is a garden world outside MS barriers. Just try to discover that world.

    Best Wished from Egyptian, arabic, Moslem brother,

    Have fun.

  • Al salamo alykom,
    Hi Mohammed how are you,
    Great to have a target to achieve, great to insist on, but not great to make your target to be another Microsoft fan!!

    I don’t hate Microsoft, or love it, But Technology != Microsoft any way.

    Try to look outside Microsoft’s circle, there is yet another world.
    What i get annoyed from some of friends who are MS fans that, they don’t see more or less than Microsoft. but again, there is a garden world outside MS barriers. Just try to discover that world.

    Best Wished from Egyptian, arabic, Moslem brother,

    Have fun.

  • Thanks, Hwedy
    You were so great
    But, I don’t prefer Microsoft all the time.
    I think Microsoft is taking the approach “pay-as-you-go,” and I hate that approach.
    I love Linux too much, also I prefer some other Microsoft products.
    But, sure I’m a great fan of Microsoft, and of course other technology industries

  • Thanks, Hwedy
    You were so great
    But, I don’t prefer Microsoft all the time.
    I think Microsoft is taking the approach “pay-as-you-go,” and I hate that approach.
    I love Linux too much, also I prefer some other Microsoft products.
    But, sure I’m a great fan of Microsoft, and of course other technology industries

  • BALAJI

    HI,
    i have seen ur article about how to send mails from our windows application…

    actually i downloaded ur application source code and try to use it but i got few runtime because of i was working in proxy enabled machine

    after i turn it off it worked once but after i did not worked and i throws error like”smtp unhandeld exception”

    my coding is

    name spaces are

    [sourcecode language=”csharp”]
    using system.net.mail;
    using System.Net.Mime;
    private void button1_Click(object sender, EventArgs e)
    {
    try
    {
    SmtpClient server = new SmtpClient();
    server.Credentials = new System.Net.NetworkCredential("xxxx@gmail.com", "password");
    server.UseDefaultCredentials = false;
    server.Port = 25;
    server.Host = "smtp.gmail.com";
    server.EnableSsl = true;
    MailMessage message = new MailMessage("xxxx@gmail.com", "yyyy@rediffmail.com");
    message.Body = "i love u";
    message.Priority = MailPriority.High;

    message.Subject = "my own mail ide";
    server.Send(message);
    }
    catch (SystemException SE)
    {
    MessageBox.Show(SE.ToString());
    }
    }[/sourcecode]

    and i’m gettin error is

    [sourcecode language=”text”]System.Net.Mail.SmtpException was unhandled
    Message="Failure sending mail."
    Source="System"
    StackTrace:
    at System.Net.Mail.SmtpClient.Send(MailMessage message)
    at Gmail.Form1.Button1_Click(Object sender, EventArgs e)
    in C:CoolCode_srcC_GmailGmailForm1.cs:line 45
    at System.Windows.Forms.Control.OnClick(EventArgs e)
    at System.Windows.Forms.Button.OnClick(EventArgs e)
    at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
    at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
    at System.Windows.Forms.Control.WndProc(Message& m)
    at System.Windows.Forms.ButtonBase.WndProc(Message& m)
    at System.Windows.Forms.Button.WndProc(Message& m)
    at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
    at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
    at System.Windows.Forms.NativeWindow.
    DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
    at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
    at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.
    UnsafeNativeMethods.IMsoComponentManager.
    FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
    at System.Windows.Forms.Application.ThreadContext.
    RunMessageLoopInner(Int32 reason, ApplicationContext context)
    at System.Windows.Forms.Application.ThreadContext.
    RunMessageLoop(Int32 reason, ApplicationContext context)
    at System.Windows.Forms.Application.Run(Form mainForm)
    at Gmail.Program.Main() in C:CoolCode_srcC_GmailGmailProgram.cs:line 17
    at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
    at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
    at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
    at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
    at System.Threading.ExecutionContext.Run
    (ExecutionContext executionContext, ContextCallback callback, Object state)
    at System.Threading.ThreadHelper.ThreadStart()[/sourcecode]

    pls tell to resolve tis problem man.i’m trying tis from last 1 month ….

    i’m waiting for ur reply …reply me as soon as possible

    • Please provide more details (e.g. InnerException).

      This should work fine:
      [sourcecode language=”csharp”]private void button1_Click(object sender, EventArgs e)
      {
      try
      {
      SmtpClient server = new SmtpClient();
      server.Credentials =
      new System.Net.NetworkCredential("xxxx@gmail.com", "password");
      server.UseDefaultCredentials = false;
      server.Port = 25;
      server.Host = "smtp.gmail.com";
      server.EnableSsl = true;
      server.DeliveryMethod = SmtpDeliveryMethod.Network;

      MailMessage message =
      new MailMessage("xxxx@gmail.com", "yyyy@rediffmail.com");
      message.Body = "i love u";
      message.Priority = MailPriority.High;
      message.Subject = "my own mail ide";

      server.Send(message);
      }
      catch (SmtpException SE)
      {
      MessageBox.Show(SE.ToString());
      }
      }[/sourcecode]

      1st. You you should set the SmtpClient.DeliveryMethod to SmtpDeliveryMethod.Network

      2nd. Never ever catch Exception, ApplicationException, or SystemException. You should handle that specific exceptions.

  • BALAJI

    HI,
    i have seen ur article about how to send mails from our windows application…

    actually i downloaded ur application source code and try to use it but i got few runtime because of i was working in proxy enabled machine

    after i turn it off it worked once but after i did not worked and i throws error like”smtp unhandeld exception”

    my coding is

    name spaces are

    [sourcecode language=”csharp”]
    using system.net.mail;
    using System.Net.Mime;
    private void button1_Click(object sender, EventArgs e)
    {
    try
    {
    SmtpClient server = new SmtpClient();
    server.Credentials = new System.Net.NetworkCredential("xxxx@gmail.com", "password");
    server.UseDefaultCredentials = false;
    server.Port = 25;
    server.Host = "smtp.gmail.com";
    server.EnableSsl = true;
    MailMessage message = new MailMessage("xxxx@gmail.com", "yyyy@rediffmail.com");
    message.Body = "i love u";
    message.Priority = MailPriority.High;

    message.Subject = "my own mail ide";
    server.Send(message);
    }
    catch (SystemException SE)
    {
    MessageBox.Show(SE.ToString());
    }
    }[/sourcecode]

    and i’m gettin error is

    [sourcecode language=”text”]System.Net.Mail.SmtpException was unhandled
    Message="Failure sending mail."
    Source="System"
    StackTrace:
    at System.Net.Mail.SmtpClient.Send(MailMessage message)
    at Gmail.Form1.Button1_Click(Object sender, EventArgs e)
    in C:\CoolCode_srcC_\Gmail\Gmail\Form1.cs:line 45
    at System.Windows.Forms.Control.OnClick(EventArgs e)
    at System.Windows.Forms.Button.OnClick(EventArgs e)
    at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
    at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
    at System.Windows.Forms.Control.WndProc(Message& m)
    at System.Windows.Forms.ButtonBase.WndProc(Message& m)
    at System.Windows.Forms.Button.WndProc(Message& m)
    at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
    at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
    at System.Windows.Forms.NativeWindow.
    DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
    at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
    at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.
    UnsafeNativeMethods.IMsoComponentManager.
    FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
    at System.Windows.Forms.Application.ThreadContext.
    RunMessageLoopInner(Int32 reason, ApplicationContext context)
    at System.Windows.Forms.Application.ThreadContext.
    RunMessageLoop(Int32 reason, ApplicationContext context)
    at System.Windows.Forms.Application.Run(Form mainForm)
    at Gmail.Program.Main() in C:\CoolCode_srcC_\Gmail\Gmail\Program.cs:line 17
    at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
    at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
    at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
    at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
    at System.Threading.ExecutionContext.Run
    (ExecutionContext executionContext, ContextCallback callback, Object state)
    at System.Threading.ThreadHelper.ThreadStart()[/sourcecode]

    pls tell to resolve tis problem man.i’m trying tis from last 1 month ….

    i’m waiting for ur reply …reply me as soon as possible

    • Please provide more details (e.g. InnerException).

      This should work fine:
      [sourcecode language=”csharp”]private void button1_Click(object sender, EventArgs e)
      {
      try
      {
      SmtpClient server = new SmtpClient();
      server.Credentials =
      new System.Net.NetworkCredential("xxxx@gmail.com", "password");
      server.UseDefaultCredentials = false;
      server.Port = 25;
      server.Host = "smtp.gmail.com";
      server.EnableSsl = true;
      server.DeliveryMethod = SmtpDeliveryMethod.Network;

      MailMessage message =
      new MailMessage("xxxx@gmail.com", "yyyy@rediffmail.com");
      message.Body = "i love u";
      message.Priority = MailPriority.High;
      message.Subject = "my own mail ide";

      server.Send(message);
      }
      catch (SmtpException SE)
      {
      MessageBox.Show(SE.ToString());
      }
      }[/sourcecode]

      1st. You you should set the SmtpClient.DeliveryMethod to SmtpDeliveryMethod.Network

      2nd. Never ever catch Exception, ApplicationException, or SystemException. You should handle that specific exceptions.

  • Asim

    Thanks, you helped me a lot with your blog
    Greetings from Bosnia and Hercegovina

  • Pingback: Anonymous()

  • Mosaed Alzamil

    حفظك الله

  • Hakim

    Assalamo Allaykom
    My name is Hakim, I live and work in Canada.
    I want to contact you about a bug in my application in WPF.
    Can you help me please.
    Thank you
    Salam