Re: Mail sent through IIS virtual SMTP server not arriving



Open the IIS Manager and check the properties for the smtp server.

In the Default SMTP Virtual Server's properties, in the "Access" tab, both
in the Connection Control and Relay dialogs, make sure that your local IP is assigned.
( In my case, it's 10.0.0.2... )

You may also need to modify your hosts file, to point 127.0.0.1 to your machine name.
( \WINDOWS\system32\drivers\etc\hosts )

Then, in your code, assign your machine name to the smtp client :

SmtpMail.SmtpServer = "YourMachineName";
SmtpMail.Send(mail);

This fixed the problem for me. I hope it does the same for you.



Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
<antonyliu2002@xxxxxxxxx> wrote in message
news:1141408994.036437.221770@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hey, Juan,

I thought that it would work this time. But the mails are still not
sent!

I am using port number 5181. I have done the following:

1. opened up this port with my Linksys WRT54G wireless router.
2. make port 5181 an exception in my WinXP Pro built-in firewall.
3. opened up this port in McAfee 8.0 Enterprise edition.
4. in Outbound connections of the SMTP properties, I set the SMTP to
listen to port 5181.
5. in the General tab, for "All unassigned", I click "Advanced" and
assigned port 5181.

Still, the messages are queued up under Inetput/mailroot/Queue/. There
is no exception.

It did not work even after I did this, i.e., on the Security tab of the
SMTP properties, I added my username as well ASPNET to "Grant operator
permissions to these windows user accounts." Of course,
'administrator' is there by default.

Hmm, kinda frustrated.

Look, this is my current code (Again, the HTML is not pasted):

Sub btnSubmit_Click(sender as object, e as EventArgs)
If Page.IsValid Then
' Create a new blank MailMessage
Dim mailMessage As MailMessage = new MailMessage ()
mailMessage.From = txtFrom.Text
mailMessage.To = txtTo.Text
mailMessage.Cc = txtCc.Text
mailMessage.Subject = "Test SMTP Message Send using port"
mailMessage.Body = txtName.Text & ", " &txtComments.Text

mailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserverport";,
"5181")
SmtpMail.SmtpServer = "127.0.0.1"
'SmtpMail.Send(mail)

Try
SmtpMail.Send(mailMessage)
Response.Write("Your E-mail has been sent sucessfully - Thank You")
Catch ex As Exception
Response.Write(("The following exception occurred: " +
ex.ToString()))
'check the InnerException
While Not (ex.InnerException Is Nothing)
Response.Write("--------------------------------<br/>")
Response.Write(("The following InnerException reported: "
+ ex.InnerException.ToString()) + "<br/>")
ex = ex.InnerException
End While
End Try
End If
End Sub



Juan T. Llibre wrote:
re:
I am using .Net Framework 1.1

Youi'll find sample code for changing the port number under system.web.amil here :

http://systemwebmail.com/faq/2.9.aspx

Essentially :


MailMessage mail = new MailMessage();
mail.To = "me@xxxxxxxxxxxxx";
mail.From = "you@xxxxxxxxxxxxxxx";
mail.Subject = "this is a test email.";
mail.Body = "Some text goes here";
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserverport";, "your port
number");
SmtpMail.SmtpServer = "YourSmtpServer";
SmtpMail.Send(mail);

There's VB.NET sample code in the same page.

Keep that systemwebmail link handy.
All the info you need to solve web mail problems under .Net 1.1 is there.

There's specific answers for both the "Could not access 'CDO.Message' object"
and "The transport failed to connect to the server" exceptions which you reported.





Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
<antonyliu2002@xxxxxxxxx> wrote in message
news:1141403139.000632.184690@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi, Juan,

Thanks a lot. Unfortunately, it looks like that the SmtpClient is only
available with .Net framework 2.0

I am using .Net Framework 1.1

I know nothing about 2.0 at this point of time. Is there any way to go
around this?

Juan T. Llibre wrote:
re:
Too bad that the .Net SmtpMail class does not let us set the port number.

But it does allow you to do that :

static void ChangePort()
{
//create the mail message
MailMessage mail = new MailMessage();

//set the addresses
mail.From = new MailAddress("me@xxxxxxxxxxxxx");
mail.To.Add("you@xxxxxxxxxxxxxxx");

//set the content
mail.Subject = "This is an email";
mail.Body = "this is the body content of the email.";

//send the message
SmtpClient smtp = new SmtpClient("127.0.0.1");

//to change the port (default is 25), we set the port property
smtp.Port = 587;
smtp.Send(mail);
}

Of course, for that to work you must set IIS's SMTP server
to the same port you set in your code. You can use any TCP port.

To do that, view the Properties of the Default SMTP Server;
click the "Delivery" tab; click the "Outbound Connections" button;
and set the port number you want in the "Tcp port" box.

That will get around your ISP's blockage of port 25.



Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
<antonyliu2002@xxxxxxxxx> wrote in message
news:1141364101.185493.190200@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi, Juan,

Now I am having the typical "Could not access 'CDO.Message' object" and
"The transport failed to connect to the server" exceptions.

------=_NextPart_000_0047_01C63EC2.E70415E0
Content-Type: text/html; charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable
X-Google-AttachSize: 6344

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.3790.2577" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>re:<BR>&gt;I am using .Net Framework
1.1<BR><BR>Youi'll find sample code for changing the port number under
system.web.amil here :<BR><BR></FONT><A
href="http://systemwebmail.com/faq/2.9.aspx";><FONT face=Arial
size=2>http://systemwebmail.com/faq/2.9.aspx</FONT></A><BR><BR><FONT face=Arial
size=2>Essentially :<BR><BR></FONT><PRE class=csharp onmouseover="this.style.cursor='hand';"
title="Click to copy to clipboard" style="CURSOR: hand" onclick=copyToClipboard(this);><FONT
face=Arial size=2>MailMessage mail = new MailMessage();
mail.To = "me@xxxxxxxxxxxxx";
mail.From = "you@xxxxxxxxxxxxxxx";
mail.Subject = "this is a test email.";
mail.Body = "Some text goes here";
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserverport";, "your port
number");
SmtpMail.SmtpServer = "YourSmtpServer";
SmtpMail.Send(mail);
</FONT></PRE><BR><FONT face=Arial size=2>There's VB.NET sample code in the same
page.<BR><BR>Keep that systemwebmail link handy.<BR>All the info you need to
solve web mail problems under .Net 1.1 is there.<BR><BR>There's specific
answers&nbsp;for both the "Could not access 'CDO.Message' object"
<BR>and&nbsp;"The transport failed to connect to the server" exceptions which
you reported.<BR></FONT></DIV>
<DIV><FONT face=Arial size=2></FONT><FONT face=Arial size=2></FONT><FONT
face=Arial size=2></FONT><FONT face=Arial size=2></FONT><FONT face=Arial
size=2></FONT><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><BR><FONT face=Arial size=2>&nbsp;<BR>Juan T. Llibre, asp.net
MVP<BR>aspnetfaq.com : </FONT><A href="http://www.aspnetfaq.com/";><FONT
face=Arial size=2>http://www.aspnetfaq.com/</FONT></A><FONT face=Arial size=2>
<BR>asp.net faq : </FONT><A href="http://asp.net.do/faq/";><FONT face=Arial
size=2>http://asp.net.do/faq/</FONT></A><BR><FONT face=Arial size=2>foros de
asp.net, en español : </FONT><A href="http://asp.net.do/foros/";><FONT face=Arial
size=2>http://asp.net.do/foros/</FONT></A><FONT face=Arial size=2>&nbsp;
<BR>===================================</FONT></DIV>
<DIV><FONT face=Arial size=2>&lt;</FONT><A
href="mailto:antonyliu2002@xxxxxxxxx";><FONT face=Arial
size=2>antonyliu2002@xxxxxxxxx</FONT></A><FONT face=Arial size=2>&gt; wrote in
message </FONT><A
href="news:1141403139.000632.184690@xxxxxxxxxxxxxxxxxxxxxxxxxxxx";><FONT
face=Arial
size=2>news:1141403139.000632.184690@xxxxxxxxxxxxxxxxxxxxxxxxxxxx</FONT></A><FONT
face=Arial size=2>...</FONT></DIV><FONT face=Arial size=2>Hi,
Juan,<BR><BR>Thanks a lot.&nbsp; Unfortunately, it looks like that the
SmtpClient is only<BR>available with .Net framework 2.0<BR></FONT><FONT
face=Arial size=2><BR>I am using .Net Framework 1.1<BR><BR>I know nothing about
2.0 at this point of time.&nbsp; Is there any way to go<BR>around
this?<BR><BR>Juan T. Llibre wrote:<BR>&gt; re:<BR>&gt; &gt;Too bad that the .Net
SmtpMail class does not let us set the port number.<BR>&gt;<BR>&gt; But it does
allow you to do that :<BR>&gt;<BR>&gt; static void ChangePort()<BR>&gt;
{<BR>&gt; //create the mail message<BR>&gt; MailMessage mail = new
MailMessage();<BR>&gt;<BR>&gt; //set the addresses<BR>&gt; mail.From = new
MailAddress("</FONT><A href="mailto:me@xxxxxxxxxxxxx";><FONT face=Arial
size=2>me@xxxxxxxxxxxxx</FONT></A><FONT face=Arial size=2>");<BR>&gt;
mail.To.Add("</FONT><A href="mailto:you@xxxxxxxxxxxxxxx";><FONT face=Arial
size=2>you@xxxxxxxxxxxxxxx</FONT></A><FONT face=Arial size=2>");<BR>&gt;<BR>&gt;
//set the content<BR>&gt; mail.Subject = "This is an email";<BR>&gt; mail.Body =
"this is the body content of the email.";<BR>&gt;<BR>&gt; //send the
message<BR>&gt; SmtpClient smtp = new SmtpClient("127.0.0.1");<BR>&gt;<BR>&gt;
//to change the port (default is 25), we set the port property<BR>&gt; smtp.Port
= 587;<BR>&gt; smtp.Send(mail);<BR>&gt; }<BR>&gt;<BR>&gt; Of course, for that to
work you must set IIS's SMTP server<BR>&gt; to the same port you set in your
code. You can use any TCP port.<BR>&gt;<BR>&gt; To do that, view the Properties
of the Default SMTP Server;<BR>&gt; click the "Delivery" tab; click the
"Outbound Connections" button;<BR>&gt; and set the port number you want in the
"Tcp port" box.<BR>&gt;<BR>&gt; That will get around your ISP's blockage of port
25.<BR>&gt;<BR>&gt;<BR>&gt;<BR>&gt; Juan T. Llibre, asp.net MVP<BR>&gt;
aspnetfaq.com : </FONT><A href="http://www.aspnetfaq.com/";><FONT face=Arial
size=2>http://www.aspnetfaq.com/</FONT></A><BR><FONT face=Arial size=2>&gt;
asp.net faq : </FONT><A href="http://asp.net.do/faq/";><FONT face=Arial
size=2>http://asp.net.do/faq/</FONT></A><BR><FONT face=Arial size=2>&gt; foros
de asp.net, en español : </FONT><A href="http://asp.net.do/foros/";><FONT
face=Arial size=2>http://asp.net.do/foros/</FONT></A><BR><FONT face=Arial
size=2>&gt; ===================================<BR>&gt; &lt;</FONT><A
href="mailto:antonyliu2002@xxxxxxxxx";><FONT face=Arial
size=2>antonyliu2002@xxxxxxxxx</FONT></A><FONT face=Arial size=2>&gt; wrote in
message<BR>&gt; </FONT><A
href="news:1141364101.185493.190200@xxxxxxxxxxxxxxxxxxxxxxxxxxxx";><FONT
face=Arial
size=2>news:1141364101.185493.190200@xxxxxxxxxxxxxxxxxxxxxxxxxxxx</FONT></A><FONT
face=Arial size=2>...<BR>&gt; Hi, Juan,<BR>&gt;<BR>&gt; Now I am having the
typical "Could not access 'CDO.Message' object" and<BR>&gt; "The transport
failed to connect to the server" exceptions.<BR></FONT></BODY></HTML>

------=_NextPart_000_0047_01C63EC2.E70415E0--


.