Wrox Programmer Forums
|
.NET Framework 2.0 For discussion of the Microsoft .NET Framework 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the .NET Framework 2.0 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 November 28th, 2008, 07:21 PM
Authorized User
 
Join Date: Feb 2007
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default Sending email in VB.net

I've found many code samples to send email in VB.net. The problem is, they all require a line such as:

Dim client As New SmtpClient("Your SMTP Server")

That works fine on my computer, but if I distribute the program to someone else, I don't know their "SMTP Server".

So how do you send email from a VB.net program when the "SMTP Server" is unknown.

Thanks.

 
Old November 29th, 2008, 10:06 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

The easy answer is: you don't. I assume you are talking about a windows app here so, what I would do, is add an option for the user to configure their mail server (much like outlook does) and write these values to a config file (a good place would be that app.config file). In your code you need to check for the existence of a value in the app.config, if it exists try and send the email, otherwise inform the user that they need to configure their mail server.

hth.
-Doug

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
.: Wrox Technical Editor / Author :.
Wrox Books 24 x 7
================================================== =========
 
Old November 29th, 2008, 10:44 PM
Authorized User
 
Join Date: Feb 2007
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks. I was afraid of that. Your solution is doable if the user can figure out what their SmtpServer is.

I don't suppose there is any way to do this if the user only uses web mail such as gmail or yahoo and doesn't have an email program on their computer?

 
Old November 30th, 2008, 11:51 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Yes this can be done. Most, if not all, web mail programs can be setup to work with outlook. To provide the most flexibility for the user you should allow them to configure to provide configuration options for all possible properties (StmpServer, Ports, etc).

hth.
-Doug

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
.: Wrox Technical Editor / Author :.
Wrox Books 24 x 7
================================================== =========





Similar Threads
Thread Thread Starter Forum Replies Last Post
Sending Email from VB.NET not using outlook hplim18 Pro VB.NET 2002/2003 2 November 23rd, 2008 04:38 AM
Problem sending email with SMTP in VB.Net Compiler Forum and Wrox.com Feedback 3 November 30th, 2007 07:25 PM
sending an email from a vb.net app badgolfer VB.NET 2002/2003 Basics 1 March 7th, 2005 09:27 PM
Sending email from VB application Dmitriy Pro VB 6 0 November 29th, 2004 04:05 PM
Sending email thru Outlook Exp. from VB with html rambhias Beginning VB 6 4 November 22nd, 2004 03:12 AM





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