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 -
Here's the code:
Thank you for your help!
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 -
Code:
'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:
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);
}
}
}
}
Comment