473,769 Members | 2,102 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 #1
11 4467
tlhintoq
3,525 Recognized Expert Specialist
TIP: When you are writing your question, there is a button on the tool bar that wraps the [code] tags around your copy/pasted code. It helps a bunch. Its the button with a '#' on it. More on tags. They're cool. Check'em out.
Mar 21 '09 #2
tlhintoq
3,525 Recognized Expert Specialist
When I execute this code to send email, it gives the following error -
What you show as an error isn't an error. Its just the history of the application running.

I suspect you just copy/pasted a big chuck of code from someplace and expected it to work.

You are lacky many 'using' statements.
Have reverenced many objects such as CDO that simply don't exist in the program as shown.
What did the console output as the exception error when it hit line 54?
Mar 21 '09 #3
tlhintoq
3,525 Recognized Expert Specialist
I just looked at the title of your post..
"sending email using C# - exited with code 0"

Do you think this message indicates an error?
Is this the first program you've built in Visual Studio?
Mar 21 '09 #4
madankarmukta
308 Contributor
Hi,

Is the code getting compiled...?

Did you added the proper reference..? Which reference you added..?

Could you please answer ..?

Thanks!
Mar 22 '09 #5
stoogots2
77 New Member
Assuming there is no error, check the local machine for email. If the mail server doesn't know the destination server/domain, or has routing disabled, email will sit on the server. If this is the case, you will need to change "localhost" to a valid relay server.
Mar 23 '09 #6
Frinavale
9,735 Recognized Expert Moderator Expert
You know, there is a nifty little quick reference on how to send an email using .NET that explains how to send an email that doesn't depend on the Microsoft CDO Library 2000....

-Frinny
Mar 23 '09 #7
minishilpi
3 New Member
tlhintoq: there were no exceptions on line 54 of the code. You are right, about it not being an error. I did receive the emails, but they were delayed by 3 days. Do you have any ideas as to why?

stoogots2: I am using the default SMTP server. How can I find out if it is aware of the destination server/domain, or has routing disabled?

I have added my ip address to the relay server list. So do you want me to use my ip address instead of using localhost?

madankarmukta: The code is being compiled fine and there were no errors.

Frinavale: I tried using that code too, but it exited with code 0. And I still hav'nt received the email. Maybe I will receive it after a couple of days.
Mar 24 '09 #8
Frinavale
9,735 Recognized Expert Moderator Expert
I've never experienced "days" of delay like you are.
Are you sure it isn't your email provider that's not working?
Have you tried using a different one? Like hotmail or gmail?
Mar 24 '09 #9
minishilpi
3 New Member
I have included the code in the website and hosted the website. Now the same code sends emails immediatley.

The code when executed locally has a very long delay (2-3 days).

So, this definitely has something to do with the Default SMTP virtual server I am using under IIS.
Mar 24 '09 #10

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
3620
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
2750
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
3469
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
9833
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
5097
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
10208
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
10038
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
9987
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
9857
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
8867
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6662
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
5444
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3952
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
2
3558
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.