dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Thread: Chage HELO message in C# email client

  1. #1
    Join Date
    Jul 2011
    Posts
    4

    Chage HELO message in C# email client

    Hallo,

    I need to change HELO/EHLO message on SMTP client in C#. I'm using standard SmtpClient C# class. Is it possible to change default HELO message settings? As default is in HELO message sending my computer hostname like "Johny-PC" I want to change this on whatever else.

    Can you help me?

    Thank you

  2. #2
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: Chage HELO message in C# email client

    Probably not a good idea, for legal reasons. Email should be archived at most places.
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  3. #3
    Join Date
    Feb 2011
    Location
    United States
    Posts
    1,016

    Re: Chage HELO message in C# email client

    I don't see any way to change this, but don't understand your objection dglienna. From some googling it appears that using "HELO <hostname>" or "HELO <fully-qualified-domain-name>" would be appropriate greetings according to the standards. I don't see anything legally wrong with it, I guess, as long as you aren't impersonating someone.

    What's your goal, kuso666?
    Best Regards,

    BioPhysEngr
    http://blog.biophysengr.net
    --
    All advice is offered in good faith only. You are ultimately responsible for effects of your programs and the integrity of the machines they run on.

  4. #4
    Join Date
    May 2010
    Posts
    7

    Re: Chage HELO message in C# email client

    Code:
    static class Program
        {
            public class SmtpClientEx : SmtpClient
            {
                private void SetClient(string client)
                {
                    typeof(SmtpClient).GetField("clientDomain", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(this, client);
                }
    
                public SmtpClientEx()
                    : base() { }
                public SmtpClientEx(string client)
                    :base()
                {
                    SetClient(client);
                }
                public SmtpClientEx(string host, string client)
                    :base(host)
                {
                    SetClient(client);
                }
                public SmtpClientEx(string host, int port, string client)
                    :base(host,port)
                {
                    SetClient(client);
                }
            }
            
            static void Main()
            {
                SmtpClientEx smtpClient = new SmtpClientEx("MyName");
            }
        }
    If your running .Net 2.0 change "clientDomain" to "localHostName".

  5. #5
    Join Date
    Jul 2011
    Posts
    4

    Re: Chage HELO message in C# email client

    yeah, it works!

    thank you, this is exactly what I was looking for ;-)

  6. #6
    Join Date
    Feb 2011
    Location
    United States
    Posts
    1,016

    Re: Chage HELO message in C# email client

    Nice, Pickles!
    Best Regards,

    BioPhysEngr
    http://blog.biophysengr.net
    --
    All advice is offered in good faith only. You are ultimately responsible for effects of your programs and the integrity of the machines they run on.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)