locked
Lotus Notes send mail using System.Net.Mail.SmtpClient

    Question

  • Hi ,

    Please let me know whether i can use System.Net.Mail.SmtpClient to send mail to lotus notes.

    Lotus notes is not installed in machine. I am trying to connect to lotus notes server through System.Net.Mail.SmtpClient . If it is possible ,let me know whether the port number has to be 25?

    Any help is highly appreciated.

     

    • Moved by eryang Monday, January 31, 2011 2:36 AM (From:.NET Base Class Library)
    Friday, January 28, 2011 10:18 AM

Answers

  • I have used the following lines of code to send email

         System.Net.Mail.MailMessage Email = new System.Net.Mail.MailMessage("test@test.com",

                     test@test.com);

                    Email.Subject = "Mail";

                    Email.Attachments.Add(attach);

                    Email.Body = "Mail.";

                    System.Net.Mail.SmtpClient client = new SmtpClient("SMTP SERVER NAME", 25);

                    client.UseDefaultCredentials = false;

                    //Credentials to be filled

                    System.Net.NetworkCredential nc = new System.Net.NetworkCredential("USERNAME", "PASSWORD");

                    client.Credentials = (System.Net.ICredentialsByHost)nc.GetCredential("SMTPSERVER NAME", 25, "Basic");

                    client.DeliveryMethod = SmtpDeliveryMethod.Network;

                    client.Send(Email);

                    fs.Flush();

                    fs.Close();

                    Email.Dispose();

     

    • Marked as answer by Ronald Vimal Monday, February 28, 2011 12:05 PM
    Monday, February 28, 2011 12:05 PM

All replies

  • I have seen a sample in the net

    string postData = "username = MyUserName&password=mysecretpassword1234";
    HttpWebRequest request = (HttpWebRequest) WebRequest.Create("http://server.com/names.nsf?Login");
    request.ContentType = "application/x-www-form-urlencoded";
    request.ContentLength = postData.Length;
    request.Method = "POST";
    request.AllowAutoRedirect = false;

    Stream requestStream = request.GetRequestStream();
    byte[] postBytes = Encoding.ASCII.GetBytes(postData);
    requestStream.Write(postBytes, 0, postBytes.Length);
    requestStream.Close();
    HttpWebResponse response = (HttpWebResponse) request.GetResponse();

    Console.WriteLine(new StreamReader(response.GetResponseStream()).ReadToEnd());
    Console.WriteLine("Headers:");
    Console.WriteLine(response.Headers.ToString());

    In the same way can we also send a mail ?

     

    Friday, January 28, 2011 11:24 AM
  • I move this thread to System.NET Namespace forum for better support.
    Eric Yang [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, January 31, 2011 2:35 AM
  • I have used the following lines of code to send email

         System.Net.Mail.MailMessage Email = new System.Net.Mail.MailMessage("test@test.com",

                     test@test.com);

                    Email.Subject = "Mail";

                    Email.Attachments.Add(attach);

                    Email.Body = "Mail.";

                    System.Net.Mail.SmtpClient client = new SmtpClient("SMTP SERVER NAME", 25);

                    client.UseDefaultCredentials = false;

                    //Credentials to be filled

                    System.Net.NetworkCredential nc = new System.Net.NetworkCredential("USERNAME", "PASSWORD");

                    client.Credentials = (System.Net.ICredentialsByHost)nc.GetCredential("SMTPSERVER NAME", 25, "Basic");

                    client.DeliveryMethod = SmtpDeliveryMethod.Network;

                    client.Send(Email);

                    fs.Flush();

                    fs.Close();

                    Email.Dispose();

     

    • Marked as answer by Ronald Vimal Monday, February 28, 2011 12:05 PM
    Monday, February 28, 2011 12:05 PM