p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   BOOK: Beginning ASP.NET 4 : in C# and VB (http://p2p.wrox.com/forumdisplay.php?f=560)
-   -   Try it out on page 319 (http://p2p.wrox.com/showthread.php?t=83129)

fredfenk March 31st, 2011 12:00 PM

Try it out on page 319
 
I have been trying to do the "Try it out" on page 319 for the last couple of days. I have been unsuccessful in everything that I have tried. I installed SP 1 in VS 2010 that I am using and it still does not work. Here is the web.config code that I am using.

<configuration>
<system.web>
<pages theme="Monochrome">
<controls>
<add tagPrefix="Wrox" tagName="Banner" src="~/Controls/Banner.ascx"/>
</controls>
</pages>
<compilation debug="true" strict="false" explicit="true" targetFramework="4.0"/>
</system.web>
<system.net>
<mailSettings>
<smtp deliveryMethod="SpecifiedPickupDirectory" from ="info@PlanetWrox.com">
<specifiedPickupDirectory pickupDirectoryLocation="c:\maildrop\"/>
<!--<smtp deliveryMethod="Network" from="Fred Fenk &lt;fwfenk3@gmail.com&gt;">
<network host="smtp.gmail.com" userName="fwfenk3@gmail.com" password="juliana0603"/>-->
</smtp>

</mailSettings>
</system.net>
</configuration>

As you can see that I have tried both of the methods that you recommended.
Below is the vb code behind the Email.aspx that you instructed for us to code in the vb code.

Dim myMessage As MailMessage = New MailMessage()
myMessage.Subject = "test message"
myMessage.Body = "Hello World, from Planet Wrox"
myMessage.From = New MailAddress("fwfenk3@gmail.net", "Fred Fenk")
myMessage.To.Add(New MailAddress("fwfenk3@gmail.net", "Fred Fenk"))

Dim mySmtpClient As SmtpClient = New SmtpClient()
mySmtpClient.Send(myMessage)

It just will not send the message. That is the error that I am getting. I am at a loss because I cannot do the next "Try it out" or anything in chapter 10 until I get this resolved.

I have tried the SpecifiedPickupDirectory and it does not work. The error keeps on pointing to the "mySmtpclient.Send(myMessage)" line of code in my VB code. I have looked on the internet for other suggestions and they talk about schemas that need to be included in the code. But if I try to just write to my c drive why would I need schemas. I cannot even write to my c drive.

Please advise, I really need help.


Fred Fenk

Imar March 31st, 2011 12:13 PM

Hi Fred,

Quote:

But if I try to just write to my c drive why would I need schemas. I cannot even write to my c drive.
You don't need schemas to make this work. However, you do need to create the folder c:\maildrop up front as explained in the book. Can you confirm the folder exists?

If I create that folder and then use your code as-is, I get a message in the maildrop folder.

For Gmail, you also need to specify a portnumber. Something like this will probably work:

<network enableSsl="true" host="smtp.gmail.com" password="YourPassword"
userName="YourAccountName@gmail.com" port="587" />

If it still doesn't work, make sure you don't have Anti Virus software or other software blocking the outgoing mail.

If you still can't make it work, please post the error message you're seeing.

Cheers,

Imar

BTW: you may want to remove your Gmail password in the post, and change the From address in your web.config so I don't have to deal with your bounce messages.... ;-)


All times are GMT -4. The time now is 05:13 PM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.