Share via


Using SmtpClient Thru a proxy

Question

Saturday, November 20, 2010 3:36 AM

I've got a vb program that sends an email using SmtpClient. I can't seem to get the message to pass the Proxy server (ccproxy). When sending thru outlook, I set the SMTP server to the Proxy server address, and in the username field I add a #and the SMTP server name following the username. I have tried several differt things here, but to no avail. Here is a sample of how I am trying to send this:

emailuserid = "[email protected]#mail.mysmtp.com"
    emailpassword = "mypassword"
    smtpserver = "192.168.0.1"
    smtpport = "25"
    from = "[email protected]"
    recepient = "[email protected]"

    Dim mMailMessage As New MailMessage()
        mMailMessage.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure
        mMailMessage.From = New MailAddress(from)
        mMailMessage.To.Add(New MailAddress(recepient))
        mMailMessage.IsBodyHtml = False
        mMailMessage.Priority = MailPriority.Normal
    mMailMessage.Subject = "hi"


        mSmtpClient.Credentials = New System.Net.NetworkCredential(emailuserid, emailpassword)
        mSmtpClient = New SmtpClient(smtpserver, port:=smtpport)
        mSmtpClient.UseDefaultCredentials = False


    mMailMessage.AlternateViews.Clear()
    
        Dim plainView As AlternateView = AlternateView.CreateAlternateViewFromString("Message", Encoding.GetEncoding("iso-8859-1"), "text/plain")
        plainView.TransferEncoding = Net.Mime.TransferEncoding.SevenBit        

        mMailMessage.AlternateViews.Add(plainView)
        mMailMessage.BodyEncoding = Encoding.GetEncoding("iso-8859-1")
        mSmtpClient.Send(mMailMessage)

Any ideas would be apreciated.

All replies (1)

Monday, November 22, 2010 5:10 AM âś…Answered

Hello Justhininabouti,

Thanks for your post.

Please check this link about this aspect. Is it helpful?

http://stackoverflow.com/questions/844835/sending-mail-throught-http-proxy

If you have any concerns, please feel free to follow up.

Best regards,
Liliane
MSDN Subscriber Support in Forum
If you have any feedback on our support, please contact [email protected]

Please mark the replies as answers if they help and unmark them if they provide no help. Welcome to the All-In-One Code Framework! If you have any feedback, please tell us. Thanks