Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP.Net V 2.0 problems with sending email

Reply
Thread Tools

ASP.Net V 2.0 problems with sending email

 
 
=?Utf-8?B?TWlrZSBPd2Vu?=
Guest
Posts: n/a
 
      07-24-2006
Hi,

I am using the following code to send email on a Windows 2003 Web Server:

Imports System.Net.Mail
........
Dim msgmail As New MailMessage
msgmail.To.Add(New
MailAddress(objMember.EmailAddress))
msgmail.From = New
MailAddress(objSiteInfo.site_admin_email)
msgmail.Subject = objSiteInfo.Name & "
registration confirmation"

msgmail.Body = eb
msgmail.IsBodyHtml = True

Dim smtp As New SmtpClient(Globals.SmtpServer)
smtp.Send(msgmail)

Sending the email using the code seems to work ok. Hwoever the email never
arrives and I get the following message as a result of the send:

Final-Recipient: rfc822;(E-Mail Removed)
Action: failed
Status: 4.0.0
Diagnostic-Code: smtp;451 Temporary local problem - please try later

I assume that the .Net code uses the local IIS V6 'Default SMTP Virtual
Server' to send the email - Is this correct?

I have 'Enable logging' on the IIS 6.0 server switched on, however I can
neither find the log file, or indeed the log file directory
'C:\Windows\System32\Logfiles\SmtpSvc1'. Does this mean that the local IIS
server is not being used to send email?

Another .Net V 2.0 program that runs on the same web server uses the older
class System.Web.Mail to send mail. This seems to work ok.

Any clues or hints as to what might be happening?


Thanks, Mike.
 
Reply With Quote
 
 
 
 
sloan
Guest
Posts: n/a
 
      07-24-2006

Mike,
I'm not sure about your specific error, but I have a 2.0 download example
at:
http://sholliday.spaces.msn.com/ 2/8/2006 entry

I'm not sure about IIS6.

Check the c:\inetpub\mailroot subfolders ... to see if the email is getting
stuck in there somewhere.



"Mike Owen" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi,
>
> I am using the following code to send email on a Windows 2003 Web Server:
>
> Imports System.Net.Mail
> .......
> Dim msgmail As New MailMessage
> msgmail.To.Add(New
> MailAddress(objMember.EmailAddress))
> msgmail.From = New
> MailAddress(objSiteInfo.site_admin_email)
> msgmail.Subject = objSiteInfo.Name & "
> registration confirmation"
>
> msgmail.Body = eb
> msgmail.IsBodyHtml = True
>
> Dim smtp As New SmtpClient(Globals.SmtpServer)
> smtp.Send(msgmail)
>
> Sending the email using the code seems to work ok. Hwoever the email

never
> arrives and I get the following message as a result of the send:
>
> Final-Recipient: rfc822;(E-Mail Removed)
> Action: failed
> Status: 4.0.0
> Diagnostic-Code: smtp;451 Temporary local problem - please try later
>
> I assume that the .Net code uses the local IIS V6 'Default SMTP Virtual
> Server' to send the email - Is this correct?
>
> I have 'Enable logging' on the IIS 6.0 server switched on, however I can
> neither find the log file, or indeed the log file directory
> 'C:\Windows\System32\Logfiles\SmtpSvc1'. Does this mean that the local

IIS
> server is not being used to send email?
>
> Another .Net V 2.0 program that runs on the same web server uses the older
> class System.Web.Mail to send mail. This seems to work ok.
>
> Any clues or hints as to what might be happening?
>
>
> Thanks, Mike.



 
Reply With Quote
 
 
 
 
Mischa Kroon
Guest
Posts: n/a
 
      07-24-2006

> Another .Net V 2.0 program that runs on the same web server uses the older
> class System.Web.Mail to send mail. This seems to work ok.
>
> Any clues or hints as to what might be happening?


No idea what is going on exactly, what might help is turning on logging to
find out what's going on:
http://www.systemnetmail.com/faq/4.10.aspx

Which is also a pretty good source of information about the class.
http://www.systemwebmail.com

is it's 1.1 counterpart.


 
Reply With Quote
 
Steven Cheng[MSFT]
Guest
Posts: n/a
 
      07-25-2006
Hello Mike,

I suggest you try turn on the network Tracing asMischa has suggested. This
is a cool feature provided in .net framework 2.0 that can help diagnostic
network component issues(such as smtp, httprequest, ....).

#How to: Configure Network Tracing
http://msdn2.microsoft.com/en-us/library/ty48b824.aspx

Also, as for the System.Net.Mail.SmtpClient class, it does not rely on the
local IIS smtp service. It can be configured to use three mail delivery
mode:

1. using network smtp server(such as Exchange server in local intranet)

2. using local IIS smtp service(first put the mail message to the IIS smtp
service's pickup directory)

3. using a 3rd party custom smtp service(specify the custom smtp service's
pickup directory and the component will put the message file there)

This can be configuerd by the SmtpClient.DeliveryMethod property:

#SmtpClient.DeliveryMethod Property
http://msdn2.microsoft.com/en-us/lib...lient.delivery
method.aspx

for example, the following code configure the smtpclient to use a network
smtp server(I've tested through a local exchange server).
sc.DeliveryMethod = SmtpDeliveryMethod.Network;
sc.Host = "remote smtp server name or ip address";

In such case, the component won't use local IIS smtpservice. If the
smtpclient is using local IIS smtp service, you can check the messages
under the smtpservice's pickup directory(you can check the path in IIS
manager). For your scenario, are you using a remote smtp server in the
local intranet? Based on the symptom you mentioned, the smtpclient has
sent out the messages to the server, but the smtp server fail to deliver
the message to the ultimate recipient. You can also try sending some mail
to the recipients in your local network environment to see whether it works.

Anyway, please feel free to post here if you have any further finding or
questions.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead



==================================================

Get notification to my posts through email? Please refer to

http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.



Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial

response from the community or a Microsoft Support Engineer within 1
business day is

acceptable. Please note that each follow up response may take approximately
2 business days

as the support professional working with you may need further investigation
to reach the

most efficient resolution. The offering is not appropriate for situations
that require

urgent, real-time or phone-based interactions or complex project analysis
and dump analysis

issues. Issues of this nature are best handled working with a dedicated
Microsoft Support

Engineer by contacting Microsoft Customer Support Services (CSS) at

http://msdn.microsoft.com/subscripti...t/default.aspx.

==================================================



This posting is provided "AS IS" with no warranties, and confers no rights.


 
Reply With Quote
 
Steven Cheng[MSFT]
Guest
Posts: n/a
 
      07-25-2006
Hello Mike,

I suggest you try turn on the network Tracing asMischa has suggested. This
is a cool feature provided in .net framework 2.0 that can help diagnostic
network component issues(such as smtp, httprequest, ....).

#How to: Configure Network Tracing
http://msdn2.microsoft.com/en-us/library/ty48b824.aspx

Also, as for the System.Net.Mail.SmtpClient class, it does not rely on the
local IIS smtp service. It can be configured to use three mail delivery
mode:

1. using network smtp server(such as Exchange server in local intranet)

2. using local IIS smtp service(first put the mail message to the IIS smtp
service's pickup directory)

3. using a 3rd party custom smtp service(specify the custom smtp service's
pickup directory and the component will put the message file there)

This can be configuerd by the SmtpClient.DeliveryMethod property:

#SmtpClient.DeliveryMethod Property
http://msdn2.microsoft.com/en-us/lib...lient.delivery
method.aspx

for example, the following code configure the smtpclient to use a network
smtp server(I've tested through a local exchange server).
sc.DeliveryMethod = SmtpDeliveryMethod.Network;
sc.Host = "remote smtp server name or ip address";

In such case, the component won't use local IIS smtpservice. If the
smtpclient is using local IIS smtp service, you can check the messages
under the smtpservice's pickup directory(you can check the path in IIS
manager). For your scenario, are you using a remote smtp server in the
local intranet? Based on the symptom you mentioned, the smtpclient has
sent out the messages to the server, but the smtp server fail to deliver
the message to the ultimate recipient. You can also try sending some mail
to the recipients in your local network environment to see whether it works.

Anyway, please feel free to post here if you have any further finding or
questions.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead



==================================================

Get notification to my posts through email? Please refer to

http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.



Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial

response from the community or a Microsoft Support Engineer within 1
business day is

acceptable. Please note that each follow up response may take approximately
2 business days

as the support professional working with you may need further investigation
to reach the

most efficient resolution. The offering is not appropriate for situations
that require

urgent, real-time or phone-based interactions or complex project analysis
and dump analysis

issues. Issues of this nature are best handled working with a dedicated
Microsoft Support

Engineer by contacting Microsoft Customer Support Services (CSS) at

http://msdn.microsoft.com/subscripti...t/default.aspx.

==================================================



This posting is provided "AS IS" with no warranties, and confers no rights.


 
Reply With Quote
 
=?Utf-8?B?TWlrZSBPd2Vu?=
Guest
Posts: n/a
 
      07-26-2006
Thanks for your help everybody!

I have switched tracing on as you suggested, and it seems as though the mail
gets sent to a queue somewhere. The last bit of the tracer file produced is
as below:

System.Net.Sockets Verbose: 0 : [2356] 00000000 : 32 35 30 20 32 2E 36 2E-30
20 3C 42 32 42 57 45 : 250 2.6.0 <B2BWE
System.Net.Sockets Verbose: 0 : [2356] 00000010 : 42 53 45 52 56 45 52 30-31
4E 73 6F 6B 4C 30 30 : BSERVER01NsokL00
System.Net.Sockets Verbose: 0 : [2356] 00000020 : 30 30 30 30 35 65 40 62-32
62 69 6E 74 65 72 6E : 00005e@b2bintern
System.Net.Sockets Verbose: 0 : [2356] 00000030 : 65 74 73 6F 6C 75 74 69-6F
6E 73 2E 63 6F 2E 75 : etsolutions.co.u
System.Net.Sockets Verbose: 0 : [2356] 00000040 : 6B 3E 20 51 75 65 75 65-64
20 6D 61 69 6C 20 66 : k> Queued mail f
System.Net.Sockets Verbose: 0 : [2356] 00000050 : 6F 72 20 64 65 6C 69 76-65
72 79 0D 0A : or delivery..
System.Net.Sockets Verbose: 0 : [2356] Exiting Socket#60068066::Receive()
-> 93#93
System.Net Verbose: 0 : [2356] Exiting SmtpClient#45004109::Send()
System.Net.Sockets Verbose: 0 : [2220] Socket#60068066:ispose()


..... Which as you can see has a bit titled 'queued mail for delivery' at the
end.

I don't get the non delivery message for at least a day, and it comes from
the web server. Presumably it is trying to deliver it from the web server,
which from what you have said sounds wrong as it is meant to be using a third
parties smtp server. It is also strange that I get the non delivery message,
yet the message itself does not get through - The must be getting sent
somehow!

As an aside nothing is in any of the 'c:\inetpub\mailroot' folders.

Any more thoughts?


"Steven Cheng[MSFT]" wrote:

> Hello Mike,
>
> I suggest you try turn on the network Tracing asMischa has suggested. This
> is a cool feature provided in .net framework 2.0 that can help diagnostic
> network component issues(such as smtp, httprequest, ....).
>
> #How to: Configure Network Tracing
> http://msdn2.microsoft.com/en-us/library/ty48b824.aspx
>
> Also, as for the System.Net.Mail.SmtpClient class, it does not rely on the
> local IIS smtp service. It can be configured to use three mail delivery
> mode:
>
> 1. using network smtp server(such as Exchange server in local intranet)
>
> 2. using local IIS smtp service(first put the mail message to the IIS smtp
> service's pickup directory)
>
> 3. using a 3rd party custom smtp service(specify the custom smtp service's
> pickup directory and the component will put the message file there)
>
> This can be configuerd by the SmtpClient.DeliveryMethod property:
>
> #SmtpClient.DeliveryMethod Property
> http://msdn2.microsoft.com/en-us/lib...lient.delivery
> method.aspx
>
> for example, the following code configure the smtpclient to use a network
> smtp server(I've tested through a local exchange server).
> sc.DeliveryMethod = SmtpDeliveryMethod.Network;
> sc.Host = "remote smtp server name or ip address";
>
> In such case, the component won't use local IIS smtpservice. If the
> smtpclient is using local IIS smtp service, you can check the messages
> under the smtpservice's pickup directory(you can check the path in IIS
> manager). For your scenario, are you using a remote smtp server in the
> local intranet? Based on the symptom you mentioned, the smtpclient has
> sent out the messages to the server, but the smtp server fail to deliver
> the message to the ultimate recipient. You can also try sending some mail
> to the recipients in your local network environment to see whether it works.
>
> Anyway, please feel free to post here if you have any further finding or
> questions.
>
> Sincerely,
>
> Steven Cheng
>
> Microsoft MSDN Online Support Lead
>
>
>
> ==================================================
>
> Get notification to my posts through email? Please refer to
>
> http://msdn.microsoft.com/subscripti...ult.aspx#notif
> ications.
>
>
>
> Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
> where an initial
>
> response from the community or a Microsoft Support Engineer within 1
> business day is
>
> acceptable. Please note that each follow up response may take approximately
> 2 business days
>
> as the support professional working with you may need further investigation
> to reach the
>
> most efficient resolution. The offering is not appropriate for situations
> that require
>
> urgent, real-time or phone-based interactions or complex project analysis
> and dump analysis
>
> issues. Issues of this nature are best handled working with a dedicated
> Microsoft Support
>
> Engineer by contacting Microsoft Customer Support Services (CSS) at
>
> http://msdn.microsoft.com/subscripti...t/default.aspx.
>
> ==================================================
>
>
>
> This posting is provided "AS IS" with no warranties, and confers no rights.
>
>
>

 
Reply With Quote
 
=?Utf-8?B?TWlrZSBPd2Vu?=
Guest
Posts: n/a
 
      07-26-2006
I take back what I just said. It has just started working. I made 2
changes, which were:

- Adding the line 'smtp.DeliveryMethod = SmtpDeliveryMethod.Network', and also
- Changing the from address.

I am not sure which one fixed it, but I think it almost certainly be the
first one. I'll change the from address back and let you know if it
continues to work.


Cheers, Mike.


Cheers, Mike.

"Mike Owen" wrote:

> Thanks for your help everybody!
>
> I have switched tracing on as you suggested, and it seems as though the mail
> gets sent to a queue somewhere. The last bit of the tracer file produced is
> as below:
>
> System.Net.Sockets Verbose: 0 : [2356] 00000000 : 32 35 30 20 32 2E 36 2E-30
> 20 3C 42 32 42 57 45 : 250 2.6.0 <B2BWE
> System.Net.Sockets Verbose: 0 : [2356] 00000010 : 42 53 45 52 56 45 52 30-31
> 4E 73 6F 6B 4C 30 30 : BSERVER01NsokL00
> System.Net.Sockets Verbose: 0 : [2356] 00000020 : 30 30 30 30 35 65 40 62-32
> 62 69 6E 74 65 72 6E : 00005e@b2bintern
> System.Net.Sockets Verbose: 0 : [2356] 00000030 : 65 74 73 6F 6C 75 74 69-6F
> 6E 73 2E 63 6F 2E 75 : etsolutions.co.u
> System.Net.Sockets Verbose: 0 : [2356] 00000040 : 6B 3E 20 51 75 65 75 65-64
> 20 6D 61 69 6C 20 66 : k> Queued mail f
> System.Net.Sockets Verbose: 0 : [2356] 00000050 : 6F 72 20 64 65 6C 69 76-65
> 72 79 0D 0A : or delivery..
> System.Net.Sockets Verbose: 0 : [2356] Exiting Socket#60068066::Receive()
> -> 93#93
> System.Net Verbose: 0 : [2356] Exiting SmtpClient#45004109::Send()
> System.Net.Sockets Verbose: 0 : [2220] Socket#60068066:ispose()
>
>
> .... Which as you can see has a bit titled 'queued mail for delivery' at the
> end.
>
> I don't get the non delivery message for at least a day, and it comes from
> the web server. Presumably it is trying to deliver it from the web server,
> which from what you have said sounds wrong as it is meant to be using a third
> parties smtp server. It is also strange that I get the non delivery message,
> yet the message itself does not get through - The must be getting sent
> somehow!
>
> As an aside nothing is in any of the 'c:\inetpub\mailroot' folders.
>
> Any more thoughts?
>
>
> "Steven Cheng[MSFT]" wrote:
>
> > Hello Mike,
> >
> > I suggest you try turn on the network Tracing asMischa has suggested. This
> > is a cool feature provided in .net framework 2.0 that can help diagnostic
> > network component issues(such as smtp, httprequest, ....).
> >
> > #How to: Configure Network Tracing
> > http://msdn2.microsoft.com/en-us/library/ty48b824.aspx
> >
> > Also, as for the System.Net.Mail.SmtpClient class, it does not rely on the
> > local IIS smtp service. It can be configured to use three mail delivery
> > mode:
> >
> > 1. using network smtp server(such as Exchange server in local intranet)
> >
> > 2. using local IIS smtp service(first put the mail message to the IIS smtp
> > service's pickup directory)
> >
> > 3. using a 3rd party custom smtp service(specify the custom smtp service's
> > pickup directory and the component will put the message file there)
> >
> > This can be configuerd by the SmtpClient.DeliveryMethod property:
> >
> > #SmtpClient.DeliveryMethod Property
> > http://msdn2.microsoft.com/en-us/lib...lient.delivery
> > method.aspx
> >
> > for example, the following code configure the smtpclient to use a network
> > smtp server(I've tested through a local exchange server).
> > sc.DeliveryMethod = SmtpDeliveryMethod.Network;
> > sc.Host = "remote smtp server name or ip address";
> >
> > In such case, the component won't use local IIS smtpservice. If the
> > smtpclient is using local IIS smtp service, you can check the messages
> > under the smtpservice's pickup directory(you can check the path in IIS
> > manager). For your scenario, are you using a remote smtp server in the
> > local intranet? Based on the symptom you mentioned, the smtpclient has
> > sent out the messages to the server, but the smtp server fail to deliver
> > the message to the ultimate recipient. You can also try sending some mail
> > to the recipients in your local network environment to see whether it works.
> >
> > Anyway, please feel free to post here if you have any further finding or
> > questions.
> >
> > Sincerely,
> >
> > Steven Cheng
> >
> > Microsoft MSDN Online Support Lead
> >
> >
> >
> > ==================================================
> >
> > Get notification to my posts through email? Please refer to
> >
> > http://msdn.microsoft.com/subscripti...ult.aspx#notif
> > ications.
> >
> >
> >
> > Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
> > where an initial
> >
> > response from the community or a Microsoft Support Engineer within 1
> > business day is
> >
> > acceptable. Please note that each follow up response may take approximately
> > 2 business days
> >
> > as the support professional working with you may need further investigation
> > to reach the
> >
> > most efficient resolution. The offering is not appropriate for situations
> > that require
> >
> > urgent, real-time or phone-based interactions or complex project analysis
> > and dump analysis
> >
> > issues. Issues of this nature are best handled working with a dedicated
> > Microsoft Support
> >
> > Engineer by contacting Microsoft Customer Support Services (CSS) at
> >
> > http://msdn.microsoft.com/subscripti...t/default.aspx.
> >
> > ==================================================
> >
> >
> >
> > This posting is provided "AS IS" with no warranties, and confers no rights.
> >
> >
> >

 
Reply With Quote
 
Steven Cheng[MSFT]
Guest
Posts: n/a
 
      07-26-2006
Hi Mike,

Thanks for your followup.

As for the two changes you made:

- Adding the line 'smtp.DeliveryMethod = SmtpDeliveryMethod.Network', and
also
================================================== =====
This will force the smtpclient to use network smtpserver and ignore whether
there is local smtp relay.


- Changing the from address.
================================================== =====
I'm not sure about your testing environment, are you in a domain and send
mail through an Exchange server. In a windows domain envionment and the
exchange server integrated with AD), it will perform validation on the
"From" address you specified, if it's not a valid address or not an address
you're authorized to use, it will report error.

Anyway, glad that you've got it working. If you meet any further problem or
anything else we can help, please feel free to post here.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead



This posting is provided "AS IS" with no warranties, and confers no rights.




 
Reply With Quote
 
Mischa Kroon
Guest
Posts: n/a
 
      07-26-2006

"Mike Owen" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I take back what I just said. It has just started working. I made 2
> changes, which were:
>
> - Adding the line 'smtp.DeliveryMethod = SmtpDeliveryMethod.Network', and
> also
> - Changing the from address.
>
> I am not sure which one fixed it, but I think it almost certainly be the
> first one. I'll change the from address back and let you know if it
> continues to work.
>
>
> Cheers, Mike.


I'm gonna make a guess here, just say I'm stupid when I'm wrong but could it
be that the website is trying to locally deliver the messages while the mx
record for the domain is elsewhere.

Aka website = host1
emails = host2

website tries to send emails for domain hosted on host2 to host1 which will
give problems unless you do add the
'smtp.DeliveryMethod = SmtpDeliveryMethod.Network'


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to get the correct email format when sending email using sqldatareader rote ASP .Net 8 04-17-2008 02:14 AM
problem sending mail: Sending the email to the following server failed Luke Java 2 03-15-2007 10:54 AM
Problems sending Email using ASP.NET Srinivas ASP .Net 3 08-22-2005 05:26 PM
Problems sending email Srinivas ASP .Net 2 04-27-2005 03:48 PM
Some problems sending an email via form Piet Puk HTML 1 04-06-2004 08:11 AM



Advertisments