Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > .NET > .NET 2.0 and Visual Studio. 2005 > .NET Framework 2.0
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
.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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old November 28th, 2008, 07:21 PM
Authorized User
 
Join Date: Feb 2007
Location: Flowery Branch, GA, USA.
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.

Reply With Quote
  #2 (permalink)  
Old November 29th, 2008, 10:06 AM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
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
================================================== =========
Reply With Quote
  #3 (permalink)  
Old November 29th, 2008, 10:44 PM
Authorized User
 
Join Date: Feb 2007
Location: Flowery Branch, GA, USA.
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?

Reply With Quote
  #4 (permalink)  
Old November 30th, 2008, 11:51 AM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
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
================================================== =========
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 10:08 PM.


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