473,396 Members | 2,033 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

i have a problem : with sending email

(using System.Net.Mail)


hi
i have this code :
Expand|Select|Wrap|Line Numbers
  1.         MailMessage myMail = new MailMessage("mail@mail.com", "mail@mail.com", "My Report.", "See the file.");
  2.         SmtpClient myccc = new SmtpClient("localhost");
  3.         myccc.Credentials = CredentialCache.DefaultNetworkCredentials;
  4.         myccc.Send(myMail);
its just tell me this message :
Failure sending mail

<edit by mod: replaced email addresses with fake ones for your privacy>
Jan 29 '09 #1
19 2109
Plater
7,872 Expert 4TB
If you look at the details of the exception that is thrown you will see what SMTP command generated the error. that might tell you more about what went wrong.
Jan 29 '09 #2
i even look at it but its not helping
please someone help me
i need it so quick
Jan 29 '09 #3
mldisibio
190 Expert 100+
Do you have a SMTP service installed and running as a Windows Service on the same machine defined as "localhost"?
Jan 30 '09 #4
Plater
7,872 Expert 4TB
Are you catching the exception as the base Exception or as an SmtpException?
The SmtpException will give you extended information about the failure.
Jan 30 '09 #5
no i haven't SMTP runing

sooo i need help give me a solution
Jan 30 '09 #6
Plater
7,872 Expert 4TB
Well if you don't have an smtp server running, how do you expect to connect to it?
Jan 30 '09 #7
Well if you don't have an smtp server running, how do you expect to connect to it?
then how can i run this thing ??
Jan 30 '09 #8
Plater
7,872 Expert 4TB
I can think of two ways:
Open up a command prompt (cmd)
and run:
net start "Simple Mail Transfer Protocol (SMTP)"

Or run services.msc and look for the SMTP service and start it.
Jan 30 '09 #9
I can think of two ways:
Open up a command prompt (cmd)
and run:
net start "Simple Mail Transfer Protocol (SMTP)"

Or run services.msc and look for the SMTP service and start it.

I do like you said but its not working
i run in cmd : net start
then i run the code but the same problem
Jan 31 '09 #10
jg007
283 100+
some more information would help as we can guess from the code but this may not always be correct as you may have just found the code and be trying to use it incorrectly

are you trying to send on a network that is using exchange servers?

are you trying to send from a specific smtp server?

if you are connecting to a smtp server where are you intending to get the logon details from as with exchange you can use your standard network credentials but I don't think you can with SMTP

I have sent some stuff via exchange so don't have a lot of experience with doing smtp but this information will help clarify things a bit
Feb 1 '09 #11
so i don't understand what are you mean exactly
but if you have another code than can i send an email please
tell me what is it
Feb 1 '09 #12
jg007
283 100+
I haven't got an exchange server at home to work out the code but try having a look at this thread -

http://bytes.com/groups/net-asp/6651...-server-2007-a

if you have any problems I will try setting something up to work it out.
Feb 2 '09 #13
jg007
283 100+
also you are pointing to your SMTP server as ' localhost ' which will redirect back to your PC, if you check the code you will see that it will usually point to a server running either exchange or an SMTP server, to confirm if it is runnning smtp you could try using telnet on port 25 unless it is set up for a different port
Feb 2 '09 #14
vekipeki
229 Expert 100+
If you are making a WinForms app, you can do it using MAPI, and use MS Outlook (or other mail client) to send your mails.

Google for ".NET MAPI" (e.g. http://www.codeproject.com/KB/IP/SendFileToNET.aspx).

This way you don't have to worry about the SMTP server, but rather pass the mail to Outlook, which will then use its own stored account settings.
Feb 2 '09 #15
OK man thanks a lot, this will help
i wish you a good luck in your life
Feb 2 '09 #16
jg007
283 100+
only problem with using outlook is that 2003 pops up a stupid message asking if you want to allow the email due to a security patch

you can bypass this by either using sendkeys to send Alt + S to send it or using a third paty dll or similar but unfortunately all the one's I have seen were quite expensive.
Feb 2 '09 #17
jg007
283 100+
looking at the code I might be incorrect as the stuff I was using previously was using the office interop stuff so I might have to try that code out.

Thanks
Feb 2 '09 #18
Plater
7,872 Expert 4TB
I use outlook without poping up security prompts.
The prompt only pops up if you attempt to do a READ on any values.
If you only do writes, it won't popup.
As dumb as that sounds.
Feb 2 '09 #19
jg007
283 100+
sounds odd, I was trying to create a message object , set the to and from etc and then send it so I am not fully sure what you mean by ' read ' but the code on the link looks quite different so I will have to have a look and see how it works
Feb 2 '09 #20

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Paul Lamonby | last post by:
Hi, I am sending a file from the server as an email attachment. The file is being attached no problem and sending the email, but I get an error when I try to open it saying it is corrupt....
0
by: praba kar | last post by:
Dear All, I have doubt regarding mail sending smtplib module. The below code is I used to send a mail. ########################################## import email.Message import email.Utils...
3
by: VB Programmer | last post by:
I have an ASPX page where I send out emails through my mail server mail.MyDomain.com. When I send emails to MyName@MyDomain.com it sends PERFECTLY. When I try sending an email to any other address...
3
by: Ant | last post by:
Hi, I'm using the MailMessage & smtpMail classes in System.Web.Mail to send mail, however it's not sending any emails. I'm using it on a Windows 2003 server. The simplest way to use this is...
1
by: Eric Sheu | last post by:
Greetings, I have been searching the web like mad for a solution to my SMTP problem. I am using Windows Server 2003 and ASP.NET 2.0 w/ C# to send out e-mails from a web site I have created to...
2
by: =?Utf-8?B?QWRl?= | last post by:
HI All, I am encountering the following error when I try to send an email through a SMTP server. I believe the problem lies with the authentication part when the network crednetials are used,...
9
by: JoeP | last post by:
Hi All, How can I find the reason for such an error: Failure sending mail. Some Code... oMailMessage.IsBodyHtml = False oMailMessage.Body = cEmailBody Dim oSMTP As New SmtpClient...
7
by: bleachie | last post by:
Hey, I just need some help, my form seems to not send me all of the 'guestNames' and 'guestEmails' forms. i use this function to add more guestnames and guestemail fields based on the number of...
10
by: Markgoldin | last post by:
I am sending an XML data from not dontnet process to a .Net via socket listener. Here is a data sample: <VFPData> <serverdata> <coderun>updateFloor</coderun> <area>MD2</area>...
31
by: happyse27 | last post by:
Hi All, I am trying for weeks how to send email from windows pc, which from my gmail account to my hotmail account. Using net::smtp module sending email failed,Kindly assist. (for the item d it...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.