none
sending mailmessage using smtp.office365.com and framework 1.1 RRS feed

  • Question

  • How I can send mailmessage using smtp.office365.com and framework 1.1 ?

    I need to use port 587 and TLS I think .

    It is possible?

    Wednesday, July 30, 2014 2:40 PM

Answers

  • System.Web.Mail is just a wrapper over CDO.Message. Most of the ways how things works can be copied.

    Try to add the following to the above code and see if it works:

    Message.Fields["http://schemas.microsoft.com/cdo/configuration/sendusername"] = "username";  
    
    Message.Fields["http://schemas.microsoft.com/cdo/configuration/sendpassword"] = "password";
    
    Message.Fields["http://schemas.microsoft.com/cdo/configuration/smtpusessl"] = true; 
    
    Message.Fields["http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"] = 1; // Basic
    
    Message.Fields["http://schemas.microsoft.com/cdo/configuration/smtpserver"] = "mail.example.com";  
    
    Message.Fields["http://schemas.microsoft.com/cdo/configuration/smtpserverport"] = 587;  
    
    Message.Fields["http://schemas.microsoft.com/cdo/configuration/sendusing"] = 2; // Send Using Port
    Btw, may also consider using your local IIS as relay.
    Thursday, August 7, 2014 1:14 AM
    Answerer

All replies

  • Hello,

    >>How I can send mailmessage using smtp.office365.com and framework 1.1 ?

    Since you are trying to working with framework, I assume that you would like to send the mail in program. With .NET Framework 1.1, you could send mail by using SmtpMail.

    >> I need to use port 587 and TLS I think .

    About the port 587, I know a little and do not it is could be used, while the TLS, you could use X.509 certificates enable Transport Layer Security, for details, you could check this support KB:

    http://support.microsoft.com/kb/829721/en-gb

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, July 31, 2014 7:53 AM
    Moderator
  • Sorry but I need and example in C# code and framework 1.1 if it's possible

    thanks


    • Edited by provmi Monday, August 4, 2014 12:49 PM
    Monday, August 4, 2014 12:48 PM
  • Hello,

    It also provides a C# exmaple below the VB example:

    //[C#] 
    using System;
    using System.Web.Mail;
     
    namespace SendMail
    {
       class usage
       {
          public void DisplayUsage()
          {
             Console.WriteLine("Usage SendMail.exe <to> <from> <subject> <body>");
             Console.WriteLine("<to> the addresses of the email recipients");
             Console.WriteLine("<from> your email address");
             Console.WriteLine("<subject> subject of your email");
             Console.WriteLine("<body> the text of the email");
             Console.WriteLine("Example:");
             Console.WriteLine("SendMail.exe SomeOne@Contoso.com;SomeOther@Contoso.com Me@contoso.com Hi hello");
          }
       }
     
    
       class Start
       {
          // The main entry point for the application.
          [STAThread]
          static void Main(string[] args)
          {
             try
             {
                try
                {
                   MailMessage Message = new MailMessage();
                   Message.To = args[0];
                   Message.From = args[1];
                   Message.Subject = args[2];
                   Message.Body = args[3];
    
                   try
                   {
                      SmtpMail.SmtpServer = "your mail server name goes here";
                      SmtpMail.Send(Message);
                   }
                   catch(System.Web.HttpException ehttp)
                   {
                      Console.WriteLine("{0}", ehttp.Message);
                      Console.WriteLine("Here is the full error message output");
                      Console.Write("{0}", ehttp.ToString());
                   }
                }
                catch(IndexOutOfRangeException)
                {
                   usage use = new usage();
                   use.DisplayUsage();
                }
             }
             catch(System.Exception e)
             {
                Console.WriteLine("Unknown Exception occurred {0}", e.Message);
                Console.WriteLine("Here is the Full Message output");
                Console.WriteLine("{0}", e.ToString());
             }
          }
       }
    }
    
    

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, August 5, 2014 5:16 AM
    Moderator
  • I think that this sample does not work using smtp.office365.com  as SMTP server.

    I need to specify port number, credentials as username and password and security settings as TLS .

    Wednesday, August 6, 2014 9:07 AM
  • System.Web.Mail is just a wrapper over CDO.Message. Most of the ways how things works can be copied.

    Try to add the following to the above code and see if it works:

    Message.Fields["http://schemas.microsoft.com/cdo/configuration/sendusername"] = "username";  
    
    Message.Fields["http://schemas.microsoft.com/cdo/configuration/sendpassword"] = "password";
    
    Message.Fields["http://schemas.microsoft.com/cdo/configuration/smtpusessl"] = true; 
    
    Message.Fields["http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"] = 1; // Basic
    
    Message.Fields["http://schemas.microsoft.com/cdo/configuration/smtpserver"] = "mail.example.com";  
    
    Message.Fields["http://schemas.microsoft.com/cdo/configuration/smtpserverport"] = 587;  
    
    Message.Fields["http://schemas.microsoft.com/cdo/configuration/sendusing"] = 2; // Send Using Port
    Btw, may also consider using your local IIS as relay.
    Thursday, August 7, 2014 1:14 AM
    Answerer