473,779 Members | 2,038 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

sending email using C# - exited with code 0

3 New Member
I have a question - I have this code below to send an email and I have referenced the Microsoft CDO Library 2000.
It doesn't throw any exception in the console window. It goes throughout the code successfully, but I do not receive any email.
When I execute this code to send email, it gives the following error -
Expand|Select|Wrap|Line Numbers
  1. 'ConsoleApplication1.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_32\mscorlib\2.0.0.0__b77a5c561934e089\mscorlib.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
  2. 'ConsoleApplication1.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\Microsoft.VisualStudio.HostingProcess.Utilities\8.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.HostingProcess.Utilities.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
  3. 'ConsoleApplication1.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\System.Windows.Forms\2.0.0.0__b77a5c561934e089\System.Windows.Forms.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
  4. 'ConsoleApplication1.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\System\2.0.0.0__b77a5c561934e089\System.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
  5. 'ConsoleApplication1.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\System.Drawing\2.0.0.0__b03f5f7f11d50a3a\System.Drawing.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
  6. 'ConsoleApplication1.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\Microsoft.VisualStudio.HostingProcess.Utilities.Sync\8.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.HostingProcess.Utilities.Sync.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
  7. 'ConsoleApplication1.vshost.exe' (Managed): Loaded 'C:\Documents and Settings\shilpi\My Documents\Visual Studio 2005\Projects\ConsoleApplication1\ConsoleApplication1\bin\Debug\ConsoleApplication1.vshost.exe', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
  8. 'ConsoleApplication1.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_32\System.Data\2.0.0.0__b77a5c561934e089\System.Data.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
  9. 'ConsoleApplication1.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\System.Xml\2.0.0.0__b77a5c561934e089\System.Xml.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
  10. The thread 0xce0 has exited with code 0 (0x0).
  11. 'ConsoleApplication1.vshost.exe' (Managed): Loaded 'C:\Documents and Settings\shilpi\My Documents\Visual Studio 2005\Projects\ConsoleApplication1\ConsoleApplication1\bin\Debug\ConsoleApplication1.exe', Symbols loaded.
  12. 'ConsoleApplication1.vshost.exe' (Managed): Loaded 'C:\Documents and Settings\shilpi\My Documents\Visual Studio 2005\Projects\ConsoleApplication1\ConsoleApplication1\bin\Debug\Interop.CDO.dll', No symbols loaded.
  13. 'ConsoleApplication1.vshost.exe' (Managed): Loaded 'C:\Documents and Settings\shilpi\My Documents\Visual Studio 2005\Projects\ConsoleApplication1\ConsoleApplication1\bin\Debug\Interop.ADODB.dll', No symbols loaded.
  14. The thread 0x1030 has exited with code 0 (0x0).
  15. The thread 0x1588 has exited with code 0 (0x0).
  16. The program '[6060] ConsoleApplication1.vshost.exe: Managed' has exited with code 0 (0x0).
  17.  


Here's the code:

Expand|Select|Wrap|Line Numbers
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4.  
  5. namespace SendMail
  6. {
  7.     using System;
  8.     class Class1
  9.     {
  10.         static void Main(string[] args)
  11.         {
  12.             try
  13.             {
  14.                 CDO.Message oMsg = new CDO.Message();
  15.                 CDO.IConfiguration iConfg;
  16.  
  17.                 iConfg = oMsg.Configuration;
  18.  
  19.                 ADODB.Fields oFields;
  20.                 oFields = iConfg.Fields;
  21.  
  22.                 // Set configuration.
  23.                 ADODB.Field oField = oFields["http://schemas.microsoft.com/cdo/configuration/sendusing"];
  24.  
  25.                 //TODO: To send by using the smart host, uncomment the following lines:
  26.                 //oField.Value = CDO.CdoSendUsing.cdoSendUsingPort;
  27.                 //oField = oFields["http://schemas.microsoft.com/cdo/configuration/smtpserver"];
  28.                 //oField.Value = "smarthost";
  29.  
  30.                 // TODO: To send by using local SMTP service.
  31.                 oField = oFields["http://schemas.microsoft.com/cdo/configuration/sendusing"];
  32.                 oField.Value = 2;
  33.                 oField = oFields["http://schemas.microsoft.com/cdo/configuration/smtpserver"];
  34.                 oField.Value = "localhost";
  35.                 oField = oFields["http://schemas.microsoft.com/cdo/configuration/smtpserverport"];
  36.                 oField.Value = 25;
  37.                 oFields.Update();
  38.  
  39.                 // Set common properties from message.
  40.  
  41.                 //TODO: To send text body, uncomment the following line:
  42.                 oMsg.TextBody = "Hello, how are you doing?";
  43.  
  44.  
  45.                 oMsg.Subject = "Test SMTP";
  46.  
  47.                 //TODO: Change the To and From address to reflect your information.                      
  48.                 oMsg.From = "minishilpi@gmail.com";
  49.                 oMsg.To = "minishilpi@gmail.com";
  50.                 oMsg.Send();
  51.             }
  52.             catch (Exception e)
  53.             {
  54.                 Console.WriteLine("{0} Exception caught.", e);
  55.             }
  56.         }
  57.     }
  58. }
  59.  
Thank you for your help!
Mar 21 '09
11 4470
Frinavale
9,735 Recognized Expert Moderator Expert
I'm glad it's working for you in the wild.
It's going to make testing while developing difficult though.
For development testing purposes would recommend using a different SMTP server than you are currently using...or look into fixing it.

Cheers!
-Frinny
Mar 24 '09 #11
stoogots2
77 New Member
Pretty interesting. I thought that by default SMTP messages timed out and generated Non-Delivery reports after 48 hours, but I guess I could be wrong. I think MS-Exchange does this by default.

Sounds like this is an email routing issue. Determine what domain you are sending email to and grab one of the email addresses, and the servername that you are sending from (you can't use localhost).

Then do this from the SMTP mail server. You should get a list of responsible servers for the recipients domain and then you can check connectivity to those mail servers that are finally listed.

1) NSLOOKUP (type from command prompt and press enter)
2) SET TYPE=MX (enter),
3) somedomain.com (enter)

then try from a different command window (but on the SMTP server itself). You are going to send a simple test email via Telnet.

1) TELNET hostname 25 (enter)
(where hostname is one of the results from your NSLOOKUP)
2) HELO yourservername (enter)
3) MAIL FROM: <someSMTPAddres s@domain.com> (enter) (this should be a valid email domain on your localhost or within your organization)
4) RCPT TO: <someuserthatyo uaresendingemai lto@domain.com> (enter)
5) DATA (enter)
6) Subject: Some Subject (enter)
7) Some text in the message (enter)
8 . (enter)
(the period in the blank line means end of message)
If you get a message accepted message, your message is on its way.

Anyway, if there is an error anywhere in your typing you will get a 500+ error you have probably typed something improperly, or the destination server is not accepting email from you.

Let me know what happens.
Mar 24 '09 #12

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

Similar topics

13
3229
by: joe215 | last post by:
I want my users to send emails from a Windows app that I am developing in Visual Basic.NET 2003. I found a good example of sending email to a SMTP server using the SmtpMail class. However, using this, it seems, that the user must install IIS on their computer. Isn't there a class that will detect whatever mail server is available on a computer and use that? How do I create this functionality without having the user add any other...
3
3621
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 smtpMail.Send("from@here.com", to@there.com, "Message subject", "Message Body") I'm sending it to my own email address on a different server using a dummy
6
2751
by: Anuradha | last post by:
Dear All How can i send mails using vb.net Thanx all
1
8182
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 the members of my organization. I think my problem is incorrectly setting the settings on my server or an authentication problem. Here is the code I have written to send a test message: -----Code Begins: Sensitive Information Replaced by -----...
21
7859
by: comp.lang.tcl | last post by:
set php {<? print_r("Hello World"); ?>} puts $php; # PRINTS OUT <? print_r("Hello World"); ?> puts When I try this within TCL I get the following error:
4
1747
by: InnoCreate | last post by:
Hi Everyone, I've added an error handler to some code and as part for the routine it logs to the application log and then sends the administrator an email. For some reason this email isn't actually being sent until the application is exited. I can step through the code and when i call the smptclient.send(message) the code executes without exception but it's not until i exit the application that i see the norton antivirus email icon in the...
9
3470
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 oSMTP.Send(oMailMessage) (in this line I am getting the above err)
7
9839
by: undbund | last post by:
Hi I am creating a newsletter system. The software should run from desktop computer (localhost) but be able to send email to anyone on the internet. Can you guys give me some ideas on how to achieve this. Thanks
10
5102
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> <zone>BOXING</zone> <status>Running</status> <job>1000139233</job>
0
9636
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9474
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10306
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10138
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10074
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9930
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6724
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5503
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4037
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.