Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > C# and C > C# 2005 > C# 2005
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
C# 2005 For discussion of Visual C# 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# 2005 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
 
 
Thread Tools Display Modes
  #1 (permalink)  
Old June 24th, 2008, 02:11 PM
Friend of Wrox
 
Join Date: Mar 2008
Location: So Cal is good enough for you, California, USA.
Posts: 133
Thanks: 15
Thanked 1 Time in 1 Post
Send a message via ICQ to iceman90289 Send a message via AIM to iceman90289
Default C# and Email

i have this code:

string Sub = "Your zip file";
string Body = "Thank you for using FileComp";

System.Net.Mail.MailMessage mailObj = new System.Net.Mail.MailMessage(Email, Email, Sub, Body); // I want to email it to myself

mailObj.Attachments.Add(new System.Net.Mail.Attachment(@"C:\zip.zip"));
            System.Net.Mail.SmtpClient smtpObj = new SmtpClient(System.Environment.MachineName);
            smtpObj.Send(mailObj);

the error says "Failure to send email"

  #2 (permalink)  
Old June 24th, 2008, 03:09 PM
Friend of Wrox
 
Join Date: Mar 2008
Location: So Cal is good enough for you, California, USA.
Posts: 133
Thanks: 15
Thanked 1 Time in 1 Post
Send a message via ICQ to iceman90289 Send a message via AIM to iceman90289
Default

i have also tried to pass my ip adress when using the SmtpClient constructor.

  #3 (permalink)  
Old June 24th, 2008, 03:39 PM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Is your local machine running an SMTP server?

-Peter
compiledthoughts.com
  #4 (permalink)  
Old June 24th, 2008, 04:02 PM
Friend of Wrox
 
Join Date: Mar 2008
Location: So Cal is good enough for you, California, USA.
Posts: 133
Thanks: 15
Thanked 1 Time in 1 Post
Send a message via ICQ to iceman90289 Send a message via AIM to iceman90289
Default

prolly not...

how do i make it send an email without doing that?

none of the code snippets for using "MailMessge" had any mention of needing to run a server.

  #5 (permalink)  
Old June 24th, 2008, 04:33 PM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Well, sending mail without an SMTP server is like running a web site without an HTTP server. You simply can't.

You need to connect to some SMTP server. As long as you have the authority to drop mail on it you can use it. Generally your ISP's SMTP server will allow you to drop "anonymous" mail as long as you are on their network. Otherwise you need to connect with some credentials to the server.

-Peter
compiledthoughts.com
  #6 (permalink)  
Old June 24th, 2008, 05:27 PM
Friend of Wrox
 
Join Date: Mar 2008
Location: So Cal is good enough for you, California, USA.
Posts: 133
Thanks: 15
Thanked 1 Time in 1 Post
Send a message via ICQ to iceman90289 Send a message via AIM to iceman90289
Default

im still kind of lost, how do i make the server? or use it?

i downloaded an SMTP server, started it. and my program can execute now without error, but when i check my email there is no message.

the software is found at http://www.softstack.com/advsmtp.html


  #7 (permalink)  
Old June 25th, 2008, 09:27 AM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

I think you are over complicating this.

You have internet connectivity. Chances are this is with an ISP. Also, chances are that they have an SMTP server as well as a POP3 server that hosts their email services on their network. Look on their support pages for instructions on setting up email clients and you'll find the SMTP server address.

Setting up your own SMTP server is a possibility but it's not trivial (although in this day it really should be).

-Peter
compiledthoughts.com
  #8 (permalink)  
Old June 25th, 2008, 12:31 PM
Friend of Wrox
 
Join Date: Mar 2008
Location: So Cal is good enough for you, California, USA.
Posts: 133
Thanks: 15
Thanked 1 Time in 1 Post
Send a message via ICQ to iceman90289 Send a message via AIM to iceman90289
Default

ok, i got the smtp server adress, but i need authentication, it said i use my verizon online name and password but how do i get that in code?

  #9 (permalink)  
Old June 25th, 2008, 12:44 PM
Friend of Wrox
 
Join Date: Mar 2008
Location: So Cal is good enough for you, California, USA.
Posts: 133
Thanks: 15
Thanked 1 Time in 1 Post
Send a message via ICQ to iceman90289 Send a message via AIM to iceman90289
Default

never mind, i did a google search

 


Thread Tools
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
Email through Gmail in C# tobriain C# 5 April 5th, 2007 08:57 AM
Email reports william.murray Access 3 May 11th, 2006 03:34 AM
email keyvanjan Classic ASP Basics 2 March 20th, 2006 12:05 AM
Email Component vikasp2p General .NET 1 September 22nd, 2004 10:19 AM



All times are GMT -4. The time now is 07:00 PM.


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