email program - connect to server w/ uName and PW

I have sent mail plenty of times using web forms, but this time I'm building an email app for windows.

The server in question needs logging into I assume, for it to work.

I can get this far...

SmtpMail.SmtpServer = "smtp.isp.com";

// SmtpMail.Send(myMessage); //error here of course because I have not logged in

I have searched around for a sample with no luck.

Anyone have a sample to log into a server THEN send the email - and even recieve

Thanks,

Zath



Answer this question

email program - connect to server w/ uName and PW

  • psikadelik

    Thanks for the input.

    I am using VS.Net 2003 btw.

    And, tried the code and get the dreaded error - "could not access the CDO.Message object.

    Trying to trace why.

    Zath


  • LloydM_APFM

    You are welcome!


  • Kevat

    In .NET Framework 2.0 you can use the SmtpClient class.


  • Jay Budzik

    Use a mailmessage and specify the fields, here is a working example:


    System.Web.Mail.MailMessage mail = new System.Web.Mail.MailMessage();
    mail.From = "pj.vandesande@gmail.com";
    mail.To = "somebody@msn.com";
    mail.Subject = "Hello message!";
    mail.Body = "Body of the message";
    mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate","1"); //basic authentication
    mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "USERNAME");
    mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "PASSWORD");

    System.Web.Mail.SmtpMail.SmtpServer = "mysmtp.server.com";

    System.Web.Mail.SmtpMail.Send( mail );




  • Giridhar

    Ok, it was the server here at work.

    Set it up to send to my work email and went right through!

    Thanks,

    Zath


  • email program - connect to server w/ uName and PW