Problem Sending Email via a web page

N

nesr235

I am trying to send an email using SMARTHOST. But I am running into
problems. Hopefully someone will be able to help.

In my web application, I have the following code ...

Imports System.Web.Mail

....


Dim mailObj As New Mail.MailMessage
Dim Hostname As String
Dim IPaddress As String

Hostname = System.Net.Dns.GetHostName()
IPaddress =
System.Net.Dns.GetHostByName(Hostname).AddressList(0).ToString
mailObj.From = _fromAddress
mailObj.To = recipient
mailObj.Cc = cc
mailObj.Bcc = bcc
mailObj.Subject = subject
mailObj.Body = bodyofnote
If attachment <> "" Then
mailObj.Attachments.Add (New
System.Web.Mail.MailAttachment(attachment))
Mail.SmtpMail.SmtpServer = IPaddress
Mail.SmtpMail.Send(mailObj)


I have tried several methods ...
1) If I put "SmartHost" in SmtpMail.SmtpServer then I get ...
"The transport failed to connect to the server."

2) This puts my IP address in SmtpMail.SmtpServer. The error I get is
.... "The message could not be sent to the SMTP server. The transport
error code was 0x800ccc15. The server response was not available"

3) If I put the IP address of our exchange server the error Message is
....
"The message could not be sent to the SMTP server. The transport
error code was 0x800ccc15. The server response was not available"

4) If I put nothing in for SmtpMail.SmtpServer then the error is ...
"The "SendUsing" configuration value is invalid."


Just for kicks, I created a windows application in the same dot net
solution, and called the very same code as my windows app that sends
the email. If I do not put anything in for SmtpMail.SmtpServer then
the email goes through with no problems.

Why would the windows application work but not the Web Application?
 
C

Cor Ligthert [MVP]

Hi,

I assume that 80% of these problems is that the used smtp server is not
fuctioning or denies this kind of use.

Mostly is trying it than with another SMTP server the solution.

Probably the best website with information about this is.

http://www.systemwebmail.net/

I hope this helps,

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top