Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. SMTP feedback from project

SMTP feedback from project

Scheduled Pinned Locked Moved C#
helpsysadminwindows-adminbeta-testingtutorial
6 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Mark F
    wrote on last edited by
    #1

    I am working on a feedback form that basically emails the server a small message. The main information that I need in the (outgoing) SMTP server for the user's account. One problem is how to find the default SMTP server on the user's machine. Considering the following code...,

    private bool GetSmtpAccountInfo()
    {
        RegistryKey key = Registry.CurrentUser.OpenSubKey(
            @"Software\Microsoft\Internet Account Manager\Accounts\00000001" );
        
        if (key != null)
        {
            DisplayName = key.GetValue("SMTP Display Name").ToString();
            DefaultEmailAddress = key.GetValue("SMTP Email Address").ToString();
            SMTPServer = key.GetValue("SMTP Server").ToString();
    
            key.Close();
            return true;
        }
    
        return false;
    }
    

    which gets the information from the registry key from the default Internet Account. This still seems to be destined for failure. Is there a better way? Any help would be greatly appreciated! Mark

    M E 2 Replies Last reply
    0
    • M Mark F

      I am working on a feedback form that basically emails the server a small message. The main information that I need in the (outgoing) SMTP server for the user's account. One problem is how to find the default SMTP server on the user's machine. Considering the following code...,

      private bool GetSmtpAccountInfo()
      {
          RegistryKey key = Registry.CurrentUser.OpenSubKey(
              @"Software\Microsoft\Internet Account Manager\Accounts\00000001" );
          
          if (key != null)
          {
              DisplayName = key.GetValue("SMTP Display Name").ToString();
              DefaultEmailAddress = key.GetValue("SMTP Email Address").ToString();
              SMTPServer = key.GetValue("SMTP Server").ToString();
      
              key.Close();
              return true;
          }
      
          return false;
      }
      

      which gets the information from the registry key from the default Internet Account. This still seems to be destined for failure. Is there a better way? Any help would be greatly appreciated! Mark

      M Offline
      M Offline
      Mohamad K Ayyash
      wrote on last edited by
      #2

      Let me first give you a tip, about never to write such sensitive code that is not portable on all systems, a better solution is to use specialized packages and technologies for that, now regarding your question I would 100% go to Perl or Python .Net embedded scripts... I hope this tip will help you..

      To follow the path, Walk with the MASTER, See through the MASTER, Be the MASTER!

      M 1 Reply Last reply
      0
      • M Mohamad K Ayyash

        Let me first give you a tip, about never to write such sensitive code that is not portable on all systems, a better solution is to use specialized packages and technologies for that, now regarding your question I would 100% go to Perl or Python .Net embedded scripts... I hope this tip will help you..

        To follow the path, Walk with the MASTER, See through the MASTER, Be the MASTER!

        M Offline
        M Offline
        Mark F
        wrote on last edited by
        #3

        Mohamad K Ayash wrote:

        Perl or Python .Net embedded scripts...

        Can you elaborate on this? Mark

        M 1 Reply Last reply
        0
        • M Mark F

          Mohamad K Ayash wrote:

          Perl or Python .Net embedded scripts...

          Can you elaborate on this? Mark

          M Offline
          M Offline
          Mohamad K Ayyash
          wrote on last edited by
          #4

          Ok this may be a bit complicated, are you planning to create a web application that sends messages to the users SMTP server, if this was the case you may use PHP or ASP.NET built in capabilities to do so and that is generally easy, or if you need it in C# you may access the SMTP port 25 which works similir to ping and hence get a request with the client's SMTP server, without the need to access the registry!! I hope this helps. Best Wishes Mark!:)

          To follow the path, Walk with the MASTER, See through the MASTER, Be the MASTER!

          1 Reply Last reply
          0
          • M Mark F

            I am working on a feedback form that basically emails the server a small message. The main information that I need in the (outgoing) SMTP server for the user's account. One problem is how to find the default SMTP server on the user's machine. Considering the following code...,

            private bool GetSmtpAccountInfo()
            {
                RegistryKey key = Registry.CurrentUser.OpenSubKey(
                    @"Software\Microsoft\Internet Account Manager\Accounts\00000001" );
                
                if (key != null)
                {
                    DisplayName = key.GetValue("SMTP Display Name").ToString();
                    DefaultEmailAddress = key.GetValue("SMTP Email Address").ToString();
                    SMTPServer = key.GetValue("SMTP Server").ToString();
            
                    key.Close();
                    return true;
                }
            
                return false;
            }
            

            which gets the information from the registry key from the default Internet Account. This still seems to be destined for failure. Is there a better way? Any help would be greatly appreciated! Mark

            E Offline
            E Offline
            Ed Poore
            wrote on last edited by
            #5

            I've done this for one project and because of company policy I couldn't access their SMTP server so I just signed up for a free gmail account and use that SMTP server to send emails to the same email account.  I can then access these emails from the web quite easily.


            My Blog[^]

            M 1 Reply Last reply
            0
            • E Ed Poore

              I've done this for one project and because of company policy I couldn't access their SMTP server so I just signed up for a free gmail account and use that SMTP server to send emails to the same email account.  I can then access these emails from the web quite easily.


              My Blog[^]

              M Offline
              M Offline
              Mark F
              wrote on last edited by
              #6

              Ed.Poore wrote:

              and because of company policy I couldn't access their SMTP server

              So you are saying that you are unable to send email through the company server? If you are sending mail, the SMTP server is the outgoing. So you have to be able to access that server (setting for the user's machine). That is the problem. The target server (for the recipient) is not.

              SmtpClient client = new SmtpClient();
              client.Host = someServerName;  // e.g. smtp-server.domain.com
              client.Port = 25;
              

              Mark

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups