Wrox Programmer Forums
|
ASP.NET 3.5 Professionals If you are an experienced ASP.NET programmer, this is the forum for your 3.5 questions. Please also see the Visual Web Developer 2008 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 3.5 Professionals section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 13th, 2010, 07:35 AM
Friend of Wrox
 
Join Date: Sep 2009
Posts: 165
Thanks: 5
Thanked 6 Times in 6 Posts
Default Struggling With Email

Hello Everyone,
Once again I am struggling with emails.
14 days ago all emails were being delivered without any error, but now none of the email is delivered neither from local site nor from hosted site.
I did not change any single letter of code in web.config and in pages.

Web config file is as follows.
Code:
<appSettings>
<add key="MailFromAddress" value="<user name>@gmail.com"/>
<add key="MailToAddress" value="<user name>@gmail.com"/>
<add key="SenderName" value="Jack"/>
<add key="ReceiverName" value="Jack"/>
<add key="SendMailOnError" value="true"/>
</appSettings>
and under system net
Code:
<system.net>
<mailSettings>
<smtp from="Jack &lt;<user name>@gmail.com&gt;" deliveryMethod="Network">
<network host="smtp.gmail.com" userName="<user name>" password="<password>" port="587" />
</smtp>
</mailSettings>
</system.net>
And the page that sends message is as follows

Code:
myMessage.From = New MailAddress(AppConfiguration.MailFromAddress, AppConfiguration.SenderName)
myMessage.To.Add(New MailAddress(AppConfiguration.MailToAddress, AppConfiguration.ReceiverName))

Dim mySmtpClient As New SmtpClient()
Try
        mySmtpClient.EnableSsl = True
        mySmtpClient.Send(myMessage)
Catch ex As Exception
        lblMessage.Text = "I Apologize, An Error Occurred While Sending Your Message. Please Try Again."
End Try
On debugging it always fires the catch block. Earlier I never had such problem with emails but for last few days none of the email is being delivered.
Is it my system problem?
Is it any port no. issue? My local site and remote site are not delivering any message.
Please tell me what could be the reason and how I make it functioning as before.

Thank you.
__________________
Jack: Founder, Developer & Owner Of JackAndGenieForever.Com

Last edited by jack_hilary; May 13th, 2010 at 07:39 AM..
 
Old May 13th, 2010, 08:45 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

Hi there.. Can you just get a better message from the exception??? If nothing is wrong, and everything works fine before, then I think more info on the error will come handy...
__________________
HTH

Gonzalo


================================================== =========
Read this if you want to know how to get a correct reply for your question.
(Took that from Doug signature and he Took that from Peter profile)
================================================== =========
My programs achieved a new certification :
WORKS ON MY MACHINE
================================================== =========
I know that CVS was evil, and now i got the
proof.
================================================== =========
 
Old May 13th, 2010, 09:14 AM
Friend of Wrox
 
Join Date: Sep 2009
Posts: 165
Thanks: 5
Thanked 6 Times in 6 Posts
Default

Hello,
I am using catch block to handle errors.
Code:
Catch ex As Exception
        lblMessage.Text = "I Apologize, An Error Occurred While Sending Your Message. Please Try Again."
But may you please tell me how I use object ex to show the actual error message rather than a label text.
So that I may check this.
Thank you.
__________________
Jack: Founder, Developer & Owner Of JackAndGenieForever.Com
 
Old May 13th, 2010, 09:29 AM
Friend of Wrox
 
Join Date: Sep 2009
Posts: 165
Thanks: 5
Thanked 6 Times in 6 Posts
Default

HI Gbianchi, using ex object I find the following error message.

The remote certificate is invalid according to the validation procedure.

Now may you please tell me what may be wrong?
Thank you
__________________
Jack: Founder, Developer & Owner Of JackAndGenieForever.Com
 
Old May 13th, 2010, 11:18 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

well.. you didn't google it?

There could be a lot of problem with it.. but Stack overflow has a nice hack to it (not a fix!, you will have to search a little about the real problem).
__________________
HTH

Gonzalo


================================================== =========
Read this if you want to know how to get a correct reply for your question.
(Took that from Doug signature and he Took that from Peter profile)
================================================== =========
My programs achieved a new certification :
WORKS ON MY MACHINE
================================================== =========
I know that CVS was evil, and now i got the
proof.
================================================== =========
 
Old May 13th, 2010, 05:17 PM
Friend of Wrox
 
Join Date: Sep 2009
Posts: 165
Thanks: 5
Thanked 6 Times in 6 Posts
Default

Hello Gbianchi,
Well a post is related to problem here but that is in C# and on converting that in VB, it is not working also ServicePointManager is reported as not declared.

Is there any server other than gmail which does not require SSL certification and that we can use for sending emails.
I have googled about the error msg. but most of the posts are regarding httphandler.

Why emails are not being sent as I did not change any code.
Thanks
__________________
Jack: Founder, Developer & Owner Of JackAndGenieForever.Com
 
Old May 13th, 2010, 08:46 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

ServicePointManager is defined in the class System.Net

You have to port the delegate to vb.net also (use any of online code translation services).
__________________
HTH

Gonzalo


================================================== =========
Read this if you want to know how to get a correct reply for your question.
(Took that from Doug signature and he Took that from Peter profile)
================================================== =========
My programs achieved a new certification :
WORKS ON MY MACHINE
================================================== =========
I know that CVS was evil, and now i got the
proof.
================================================== =========
 
Old May 14th, 2010, 02:57 AM
Friend of Wrox
 
Join Date: Sep 2009
Posts: 165
Thanks: 5
Thanked 6 Times in 6 Posts
Default

Hello,
Now I can access the ServicePointManager but when I convert the given code (C#)
Code:
ServicePointManager.ServerCertificateValidationCallback = delegate(object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { return true; };
into vb.net then it is as follows

Code:
ServicePointManager.ServerCertificateValidationCallback = Function(s As Object, certificate As X509Certificates, chain As X509Chain, sslPolicyErrors As SslPolicyErrors) True
But it does not seems to be correct, If I manually change the Function with Delegate keyword in vb code then it reports as expression expected.

May you please suggest the correct vb.net code.
__________________
Jack: Founder, Developer & Owner Of JackAndGenieForever.Com
 
Old May 14th, 2010, 09:27 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

I don't have a real clue, but ServerCertificate... is a property.

Example of use in vb.net.
__________________
HTH

Gonzalo


================================================== =========
Read this if you want to know how to get a correct reply for your question.
(Took that from Doug signature and he Took that from Peter profile)
================================================== =========
My programs achieved a new certification :
WORKS ON MY MACHINE
================================================== =========
I know that CVS was evil, and now i got the
proof.
================================================== =========
 
Old May 15th, 2010, 12:19 AM
Friend of Wrox
 
Join Date: Sep 2009
Posts: 165
Thanks: 5
Thanked 6 Times in 6 Posts
Default

Hello Gbianchi,
Well I tried my yahoo account and set the smtp server accordingly, then it worked fine for the local site, but I am still having problem with the remote site. Using exception object I get only this message
"sending email failed"
May you point out the error. Why it is happening with the remote site in case of yahoo account.
And I also wanna know that How & Why the certificate for google accounts has been invalid after 7 months. Do you also face the same certificate invalid problem with your gmail account while sending mails in website?

And How We can make validate it again so that it works fine as earlier

Thank you
__________________
Jack: Founder, Developer & Owner Of JackAndGenieForever.Com

Last edited by jack_hilary; May 15th, 2010 at 12:28 AM..





Similar Threads
Thread Thread Starter Forum Replies Last Post
Struggling With Email jack_hilary BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 11 May 19th, 2010 11:20 AM
C# and Email iceman90289 C# 2005 8 June 25th, 2008 11:44 AM
XML Parsing Still Struggling SCADA_Monkey XML 1 March 13th, 2007 03:59 AM
email keyvanjan Classic ASP Basics 2 March 20th, 2006 12:05 AM
Struggling with Configuration RPG SEARCH ASP.NET 1.0 and 1.1 Basics 3 September 29th, 2004 03:06 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.