Here's code:
using
System;using System.Drawing;
using System.Data;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Web;
using System.Web.Services;
using System.Web.Mail;
string filename = "c:\\stuff.xls"
MailMessage send =
send.To = "validmail@mymailserver.com";
send.From = "validmail@mymailserver.com";
send.Subject = "[MessageTitle]";
send.Priority = MailPriority.High;
send.Body = "Please see attached";
MailAttachment MyAttachment = new MailAttachment(filename);
send.Attachments.Add(MyAttachment);
SmtpMail.SmtpServer = "10.10.10.1";//the IP address of out Exchange Server
SmtpMail.Send(send);
Here's the error I get when I attempt to run it:
System.Web.HttpException: Could not access 'CDO.Message' object. ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Runtime.InteropServices.COMException (0x800C000D): The specified protocol is unknown.
--- End of inner exception stack trace ---at System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture, String[] namedParameters)
at System.RuntimeType.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParameters)
at System.Type.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args)
at System.Web.Mail.LateBoundAccessHelper.CallMethod(Type type, Object obj, String methodName, Object[] args)
at System.Web.Mail.LateBoundAccessHelper.CallMethod(Object obj, String methodName, Object[] args)
--- End of inner exception stack trace ---
at System.Web.Mail.LateBoundAccessHelper.CallMethod(Object obj, String methodName, Object[] args)
at System.Web.Mail.CdoSysHelper.Send(MailMessage message)
at System.Web.Mail.SmtpMail.Send(MailMessage message)
I've read a *lot* of web articles and tried many of them. I've tried running this with the SMTP server set as "localhost" and ensured that IIS is set to forward, but nothing seems to work. It *seems* to work ok (though the message is never delivered) if I take the attachment off, which makes me think that it's not something to do with the smtp server, but I'm open to suggestions.
Thanks
Kevon

How to send mail from a Windows Application??
David Xiong
If anti-virus is enabled on your system.....then it would block the mail from going....try disabling and then sending the mail.
FrankVS
Martyburns
http://www.systemwebmail.com/faq/4.2.8.aspx
BTW - Microsoft has deprecated System.Web.Mail in favour of the new System.Net.Mail that ships with .NET Framework 2.0.
david cantrill
Kevon
shal69503
Do we know when .NET 2 is to be released publicly This actual application is not a high priority.
Kevon
nfaustino
dys
Few other things to look at... It definitely sounds like an issue with CDO. Have you verified that you have the latest version of CDO installed on your system Have you tried to run your code on a clean machine to ensure it's not something with your particular configuration
Geeter
The machine that I am running this on is a brand new installation of XP Pro, with VS.NET 2003. How do I check what version of CDO I have What is CDO
Silvina
Here is the low-down on CDO (Collaboration Data Objects):
http://msdn.microsoft.com/library/default.asp url=/library/en-us/exchanchor/htms/msexchsvr_cdo_top.asp
cdosys.dll (CDO v2) originally shipped with Windows 2000 Server and is now part of Windows 2000, Windows XP, and Windows Server 2003. You can find it in c:\Windows\System32\cdosys.dll. The file version on my Windows XP Pro SP1 is v6.0.6015.0 and on my Windows XP Pro SP2 is 6.2.2.0.
The System.Web.Mail namespace wraps around functionality provided by cdosys.dll.
Does this shed any light on your problem
RedDawg
13Cats
mgsk
Have you tried the other suggestions listed in the FAQ that are not permission related For instance, your exception message also states "The specified protocol is unknown", which relates to:
http://www.systemwebmail.com/faq/4.3.6.aspx
Geoff Stockham
David Smith from MSU!
Kevon