-2

i need to send an email from the company SMTP server but i need to go through proxy (because i am unable to connect to the internet unless i go through a proxy,the email server can send to the outside world, but i am trying to send from a the application server an email through the email server that i have, but the application server that i am using can access the outside world only through proxy), below is my code:

    Imports System.Net.Mail
    Imports System.Net

    Dim mm As New System.Net.Mail.SmtpClient
    mm.EnableSsl = True
    mm.Host = "mail.company.net"
    mm.Credentials = New NetworkCredential("user", "pass") 
    Dim w As New MailMessage()
    w = New MailMessage()
    w.Subject = "test"
    Dim mailAddress As New System.Net.Mail.MailAddress("support@company.net", "Support")
    w.From = mailAddress
    Dim Em As New MailAddress("em@company.net")
    w.To.Add(em)
    w.IsBodyHtml = True
    w.Body = sbody
    mm.Send(w)

please can you help.

User7291
  • 1,095
  • 3
  • 29
  • 71
  • What exactly is the problem? Also on a separate note, you don't need `w = New MailMessage()` as you've already declared it `New` on the previous line. Quick search on here produced [this](http://stackoverflow.com/questions/8884306/proxy-with-smtp) which may help. – Bugs Dec 13 '16 at 15:04
  • @sloth i already saw this question, and i tried the solution but it did not work – User7291 Dec 14 '16 at 15:58

1 Answers1

0

I don't think the proxy has anything to do with your problem. If your email server can send email to the outside world then that part of the problem has been solved by whoever setup the email server. After all your application is not going through the proxy the email server is. So the problem is your application is not convincing the email server that it is trusted enough to send email to the outside world. This is a common configuration for company email servers. If the server doesn't think your application is a trusted user it will send email to internal addresses, but not external addresses.

Chestdawg
  • 58
  • 7
  • no you don't understand, the email server can send to the outside world, but i am trying to send from a the application server an email through the email server that i have, but the application server that i am using can access the outside world only through proxy. – User7291 Dec 14 '16 at 15:56
  • I'm not sure what you are saying. Are you saying A) that you are trying to send email from you application server through the separate working company email server, or B) that you have your own email server on your application server that you are trying to configure to get through the proxy server? If A) then your problem is likely authenticating with the email server, if B) then your problem is configuring your private email server to get through the proxy. – Chestdawg Dec 14 '16 at 21:30
  • When you send email, no packets go directly from the application server through the proxy to the outside world. They go to the email server and the email server sends them out through the proxy. – Chestdawg Dec 14 '16 at 21:30