C# APP:How to send a mail

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • winbala
    New Member
    • Mar 2008
    • 13

    C# APP:How to send a mail

    Hi Friends,,


    I have developed in my project c# .net . windows application. i will send any mail thru my application. i dont know.. any other know tell me.. give code.





    Regards,

    bala
  • dip_developer
    Recognized Expert Contributor
    • Aug 2006
    • 648

    #2
    Originally posted by winbala
    Hi Friends,,

    I have developed in my project c# .net . windows application. i will send any mail thru my application. i dont know.. any other know tell me.. give code.

    Regards,

    bala
    [CODE=csharp]
    MailMessage objEmail = new MailMessage();
    objEmail.To = txtTo.Text;
    objEmail.From = txtFrom.Text;
    objEmail.Cc = txtCc.Text;
    objEmail.Subjec t = "Test Email";
    objEmail.Body = txtName.Text + ", " +
    txtComments.Tex t;
    objEmail.Priori ty = MailPriority.Hi gh;
    //SmtpMail.SmtpSe rver = "localhost" ;
    try{
    SmtpMail.Send(o bjEmail);
    Response.Write( "Your Email has been sent sucessfully -
    Thank You");
    }
    catch (Exception exc){
    Response.Write( "Send failure: " + exc.ToString()) ;
    }
    [/CODE]

    Comment

    • winbala
      New Member
      • Mar 2008
      • 13

      #3
      Thanks. i want from any from address to any to address .. i will send mail..

      example my client domain name id to yahoo or gmail or hotmail anything.


      or

      i will send yahoo from gmail or hotmail



      regards
      bala

      Comment

      • Plater
        Recognized Expert Expert
        • Apr 2007
        • 7872

        #4
        Does hotmail allow smtp usage? I know google will but you have to manually enable it in the account settings.

        If you have a valid SMTP server (and user credentials) you can send to anywhere.

        Comment

        Working...