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 - -
'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.
-
'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.
-
'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.
-
'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.
-
'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.
-
'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.
-
'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.
-
'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.
-
'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.
-
The thread 0xce0 has exited with code 0 (0x0).
-
'ConsoleApplication1.vshost.exe' (Managed): Loaded 'C:\Documents and Settings\shilpi\My Documents\Visual Studio 2005\Projects\ConsoleApplication1\ConsoleApplication1\bin\Debug\ConsoleApplication1.exe', Symbols loaded.
-
'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.
-
'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.
-
The thread 0x1030 has exited with code 0 (0x0).
-
The thread 0x1588 has exited with code 0 (0x0).
-
The program '[6060] ConsoleApplication1.vshost.exe: Managed' has exited with code 0 (0x0).
-
Here's the code: -
using System;
-
using System.Collections.Generic;
-
using System.Text;
-
-
namespace SendMail
-
{
-
using System;
-
class Class1
-
{
-
static void Main(string[] args)
-
{
-
try
-
{
-
CDO.Message oMsg = new CDO.Message();
-
CDO.IConfiguration iConfg;
-
-
iConfg = oMsg.Configuration;
-
-
ADODB.Fields oFields;
-
oFields = iConfg.Fields;
-
-
// Set configuration.
-
ADODB.Field oField = oFields["http://schemas.microsoft.com/cdo/configuration/sendusing"];
-
-
//TODO: To send by using the smart host, uncomment the following lines:
-
//oField.Value = CDO.CdoSendUsing.cdoSendUsingPort;
-
//oField = oFields["http://schemas.microsoft.com/cdo/configuration/smtpserver"];
-
//oField.Value = "smarthost";
-
-
// TODO: To send by using local SMTP service.
-
oField = oFields["http://schemas.microsoft.com/cdo/configuration/sendusing"];
-
oField.Value = 2;
-
oField = oFields["http://schemas.microsoft.com/cdo/configuration/smtpserver"];
-
oField.Value = "localhost";
-
oField = oFields["http://schemas.microsoft.com/cdo/configuration/smtpserverport"];
-
oField.Value = 25;
-
oFields.Update();
-
-
// Set common properties from message.
-
-
//TODO: To send text body, uncomment the following line:
-
oMsg.TextBody = "Hello, how are you doing?";
-
-
-
oMsg.Subject = "Test SMTP";
-
-
//TODO: Change the To and From address to reflect your information.
-
oMsg.From = "minishilpi@gmail.com";
-
oMsg.To = "minishilpi@gmail.com";
-
oMsg.Send();
-
}
-
catch (Exception e)
-
{
-
Console.WriteLine("{0} Exception caught.", e);
-
}
-
}
-
}
-
}
-
Thank you for your help!
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. 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?
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?
Hi,
Is the code getting compiled...?
Did you added the proper reference..? Which reference you added..?
Could you please answer ..?
Thanks!
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.
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.
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?
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.
Sign in to post your reply or Sign up for a free account.
Similar topics |
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...
|
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
|
by: Anuradha |
last post by:
Dear All
How can i send mails using vb.net
Thanx all
|
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 -----...
|
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:
| |
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...
|
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)
|
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
|
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>
|
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...
|
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...
| |
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,...
|
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...
|
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...
|
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();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |