SMTPMAIL

Discussion in 'ASP .Net' started by aslantifosi, Jun 23, 2005.

  1. aslantifosi

    aslantifosi Guest

    hi all,
    My question is about that i use a smpt server which is running on a
    different machine from my webserver machine. And i can authenticate with a
    user and password. I use SmtpMail class. i set the smtpserver property. but
    how can i authenticate with my user and pass?

    for ex:
    my user :
    pass :12345

    Message.From = myuser;
    Message.To=strTo;

    Message.Subject=strSubject;

    Message.Body = strBody;

    try

    {

    SmtpMail.SmtpServer = "172.19.1.123";

    SmtpMail.Send(Message);

    }

    catch(System.Web.HttpException ehttp)

    {



    }
    aslantifosi, Jun 23, 2005
    #1
    1. Advertising

  2. As you can see, there's no classes in system.web.mail
    which allow for sender authentication :

    ..Net Framework 1.1 :
    http://www.csharpfriends.com/quicks...b/classbrowser.aspx?namespace=System.Web.Mail

    ..Net Framework 2.0 :
    http://beta.asp.net/quickstart/util/classbrowser.aspx?namespace=System.Web.Mail

    However, you can *add the authentication schemas* :

    private void Page_Load(object sender, System.EventArgs e)
    {

    MailMessage mail = new MailMessage();
    mail.To = "";
    mail.From = "";
    mail.Subject = "this is the subject.";
    mail.Body = "this is the body";

    //add schema for basic authentication
    mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
    // if you want NTLM authentication, use "2" !

    //set the username
    mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "the_username");

    //set the password
    mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "the_password");

    //your mail server's name goes here
    SmtpMail.SmtpServer = "mail.server.com";

    // finally, send the user-authenticated mail
    SmtpMail.Send(mail);
    }

    ---000---

    Check it out, and let me know if that works for you.



    Juan T. Llibre
    ASP.NET MVP
    http://asp.net.do/foros/
    Foros de ASP.NET en Español
    Ven, y hablemos de ASP.NET...
    ======================

    "aslantifosi" <> wrote in message news:%...
    > hi all,
    > My question is about that i use a smpt server which is running on a
    > different machine from my webserver machine. And i can authenticate with a
    > user and password. I use SmtpMail class. i set the smtpserver property. but
    > how can i authenticate with my user and pass?
    >
    > for ex:
    > my user :
    > pass :12345
    >
    > Message.From = myuser;
    > Message.To=strTo;
    >
    > Message.Subject=strSubject;
    >
    > Message.Body = strBody;
    >
    > try
    >
    > {
    >
    > SmtpMail.SmtpServer = "172.19.1.123";
    >
    > SmtpMail.Send(Message);
    >
    > }
    >
    > catch(System.Web.HttpException ehttp)
    >
    > {
    >
    >
    >
    > }
    >
    >
    >
    Juan T. Llibre, Jun 23, 2005
    #2
    1. Advertising

  3. aslantifosi

    aslantifosi Guest

    Thanks a lot.
    Bu i can't test immediately. After the test, i'll return a message to group.
    "Juan T. Llibre" <> wrote in message news:%23iIhFB$...
    As you can see, there's no classes in system.web.mail
    which allow for sender authentication :

    .Net Framework 1.1 :
    http://www.csharpfriends.com/quicks...b/classbrowser.aspx?namespace=System.Web.Mail

    .Net Framework 2.0 :
    http://beta.asp.net/quickstart/util/classbrowser.aspx?namespace=System.Web.Mail

    However, you can *add the authentication schemas* :

    private void Page_Load(object sender, System.EventArgs e)
    {

    MailMessage mail = new MailMessage();
    mail.To = "";
    mail.From = "";
    mail.Subject = "this is the subject.";
    mail.Body = "this is the body";

    //add schema for basic authentication
    mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
    // if you want NTLM authentication, use "2" !

    //set the username
    mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "the_username");

    //set the password
    mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "the_password");

    //your mail server's name goes here
    SmtpMail.SmtpServer = "mail.server.com";

    // finally, send the user-authenticated mail
    SmtpMail.Send(mail);
    }

    ---000---

    Check it out, and let me know if that works for you.



    Juan T. Llibre
    ASP.NET MVP
    http://asp.net.do/foros/
    Foros de ASP.NET en Español
    Ven, y hablemos de ASP.NET...
    ======================

    "aslantifosi" <> wrote in message news:%...
    > hi all,
    > My question is about that i use a smpt server which is running on a
    > different machine from my webserver machine. And i can authenticate with a
    > user and password. I use SmtpMail class. i set the smtpserver property. but
    > how can i authenticate with my user and pass?
    >
    > for ex:
    > my user :
    > pass :12345
    >
    > Message.From = myuser;
    > Message.To=strTo;
    >
    > Message.Subject=strSubject;
    >
    > Message.Body = strBody;
    >
    > try
    >
    > {
    >
    > SmtpMail.SmtpServer = "172.19.1.123";
    >
    > SmtpMail.Send(Message);
    >
    > }
    >
    > catch(System.Web.HttpException ehttp)
    >
    > {
    >
    >
    >
    > }
    >
    >
    >
    aslantifosi, Jun 23, 2005
    #3
  4. aslantifosi

    Frankie Guest

    I can verify that your suggestion works. I've had it going for several months with no problems.

    -Frankie


    "Juan T. Llibre" <> wrote in message news:%23iIhFB$...
    As you can see, there's no classes in system.web.mail
    which allow for sender authentication :

    .Net Framework 1.1 :
    http://www.csharpfriends.com/quicks...b/classbrowser.aspx?namespace=System.Web.Mail

    .Net Framework 2.0 :
    http://beta.asp.net/quickstart/util/classbrowser.aspx?namespace=System.Web.Mail

    However, you can *add the authentication schemas* :

    private void Page_Load(object sender, System.EventArgs e)
    {

    MailMessage mail = new MailMessage();
    mail.To = "";
    mail.From = "";
    mail.Subject = "this is the subject.";
    mail.Body = "this is the body";

    //add schema for basic authentication
    mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
    // if you want NTLM authentication, use "2" !

    //set the username
    mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "the_username");

    //set the password
    mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "the_password");

    //your mail server's name goes here
    SmtpMail.SmtpServer = "mail.server.com";

    // finally, send the user-authenticated mail
    SmtpMail.Send(mail);
    }

    ---000---

    Check it out, and let me know if that works for you.



    Juan T. Llibre
    ASP.NET MVP
    http://asp.net.do/foros/
    Foros de ASP.NET en Español
    Ven, y hablemos de ASP.NET...
    ======================

    "aslantifosi" <> wrote in message news:%...
    > hi all,
    > My question is about that i use a smpt server which is running on a
    > different machine from my webserver machine. And i can authenticate with a
    > user and password. I use SmtpMail class. i set the smtpserver property. but
    > how can i authenticate with my user and pass?
    >
    > for ex:
    > my user :
    > pass :12345
    >
    > Message.From = myuser;
    > Message.To=strTo;
    >
    > Message.Subject=strSubject;
    >
    > Message.Body = strBody;
    >
    > try
    >
    > {
    >
    > SmtpMail.SmtpServer = "172.19.1.123";
    >
    > SmtpMail.Send(Message);
    >
    > }
    >
    > catch(System.Web.HttpException ehttp)
    >
    > {
    >
    >
    >
    > }
    >
    >
    >
    Frankie, Jun 23, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. James J. Foster

    smtpMail Class

    James J. Foster, Jun 30, 2003, in forum: ASP .Net
    Replies:
    3
    Views:
    1,035
    Renato Giron
    Jun 30, 2003
  2. Kevin Spencer

    SMTPMAIL on Windows Server 2003

    Kevin Spencer, Jul 29, 2003, in forum: ASP .Net
    Replies:
    9
    Views:
    1,565
    Jim Cheshire
    Jul 30, 2003
  3. Leonard
    Replies:
    2
    Views:
    625
    Leonard
    Aug 20, 2003
  4. Jibu
    Replies:
    3
    Views:
    512
    Jurjen de Groot
    Aug 26, 2003
  5. Leszek
    Replies:
    2
    Views:
    479
    Sherif ElMetainy
    Aug 26, 2003
Loading...

Share This Page