Wrox Programmer Forums
|
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 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 June 24th, 2008, 01:11 PM
Friend of Wrox
 
Join Date: Mar 2008
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"

 
Old June 24th, 2008, 02:09 PM
Friend of Wrox
 
Join Date: Mar 2008
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.

 
Old June 24th, 2008, 02:39 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Is your local machine running an SMTP server?

-Peter
compiledthoughts.com
 
Old June 24th, 2008, 03:02 PM
Friend of Wrox
 
Join Date: Mar 2008
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.

 
Old June 24th, 2008, 03:33 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
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
 
Old June 24th, 2008, 04:27 PM
Friend of Wrox
 
Join Date: Mar 2008
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


 
Old June 25th, 2008, 08:27 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
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
 
Old June 25th, 2008, 11:31 AM
Friend of Wrox
 
Join Date: Mar 2008
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?

 
Old June 25th, 2008, 11:44 AM
Friend of Wrox
 
Join Date: Mar 2008
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






Similar Threads
Thread Thread Starter Forum Replies Last Post
Email through Gmail in C# tobriain C# 5 April 5th, 2007 07:57 AM
Email reports william.murray Access 3 May 11th, 2006 02:34 AM
email keyvanjan Classic ASP Basics 2 March 20th, 2006 12:05 AM
Email Component vikasp2p General .NET 1 September 22nd, 2004 09:19 AM





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