I'm dynamically creating an Excel file using ODBC (server doesn't have Excel installed). This works fine. The problem comes when I try to email it. I set up a basic email which works fine:
Now I add the attachment:
And it breaks. I get this error:
Any ideas?
Jon
"I don't regret this, but I both rue and lament it.
Code:
MailMessage m = new MailMessage();
m.From = aParams["emailFrom"];
m.To = aParams["emailTo"];
m.Subject = "Subject";
m.Body = body;
m.BodyFormat = MailFormat.Text;
SmtpMail.Send(m);
Code:
MailMessage m = new MailMessage();
m.From = aParams["emailFrom"];
m.To = aParams["emailTo"];
m.Subject = "Subject";
m.Body = body;
m.BodyFormat = MailFormat.Text;
MailAttachment xls = new MailAttachment(fileName);
m.Attachments.Add(xls);
SmtpMail.Send(m);
Code:
Exception occurred: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.Web.Mail.LateBoundAccessHelper.CallMethod(Object obj, String methodName, Object[] args)
The specified protocol is unknown.
Jon
"I don't regret this, but I both rue and lament it.