Equivalent of smtpmail

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • cmrhema
    Contributor
    • Jan 2007
    • 375

    Equivalent of smtpmail

    Hi
    What's the equivalent of smtpmail in vb.net 2005.
    Its not valid (it has become obsolete)

    Help needed please
  • radcaesar
    Recognized Expert Contributor
    • Sep 2006
    • 759

    #2
    MIME, POP3 & IMAP are others. Why shouldn't u prefer SMTP ? Reason Obsolete was not acceptable and its not.

    Comment

    • RoninZA
      New Member
      • Jul 2007
      • 78

      #3
      cmrhema - try looking in the System.Net.Mail namespace, where you'd use the MailMessage and SmtpClient objects ;)

      Comment

      • christopherpond
        New Member
        • Jul 2007
        • 26

        #4
        Here is a common method I created that I use for many web applications.

        Code:
        private static void SendEmail(MailAddressCollection PMailTo,
                                MailAddress PObjMailFrom,
                                string PstrMessage, string PstrSubject)
                {
        
                    string LstrSMTPHostName;
                    MailMessage LobjMailMessage;
                    SmtpClient LobjSmtpClient;
        
                    // - Intialize the SMTP Client
                    SmtpSection smtpSec = (SmtpSection)ConfigurationManager.GetSection("system.net/mailSettings/smtp");
                    LstrSMTPHostName = smtpSec.Network.Host;
                    LobjSmtpClient = new SmtpClient(LstrSMTPHostName);
                    LobjSmtpClient.UseDefaultCredentials = true;
        
                    // - Initialize Mail Message
                    LobjMailMessage = new MailMessage();
        
                    foreach (MailAddress MailAddress in PMailTo)
                    {
                        LobjMailMessage.To.Add(MailAddress);
                    }
                    LobjMailMessage.From = PObjMailFrom;
                    LobjMailMessage.Subject = PstrSubject;
                    LobjMailMessage.Body = PstrMessage;
                    
                    LobjSmtpClient.Send(LobjMailMessage);
                }

        Comment

        • christopherpond
          New Member
          • Jul 2007
          • 26

          #5
          The code above is dependent on having the following section in your web.config.

          Code:
            <system.net>
            <mailSettings>
             <smtp from="">
              <network host="" password="" userName="" />
             </smtp>
            </mailSettings>
           </system.net>

          Comment

          • cmrhema
            Contributor
            • Jan 2007
            • 375

            #6
            Originally posted by christopherpond
            The code above is dependent on having the following section in your web.config.

            Code:
              <system.net>
              <mailSettings>
               <smtp from="">
                <network host="" password="" userName="" />
               </smtp>
              </mailSettings>
             </system.net>

            Thanks a lot all of you

            I have changed my code
            http://www.thescripts. com/forum/thread682306.ht ml
            But there seems another problem

            Any way thanks a bunch

            Comment

            Working...