On 4 Jan, 13:59, JimJob <Jim...@discuss ions.microsoft. comwrote:
Thanks developer - but no joy. *I have also tried @ C:\ or C:/ to no avail
"DeveloperX " wrote:
On 4 Jan, 11:44, JimJob <Jim...@discuss ions.microsoft. comwrote:
Hi All,
I am using c# to build an application. I want a button that will be able to
open a new mail message with an attachment. *The new mail message works but I
can't get the attachment to work - there is no error message just no
attachment. *Any ideas? *Code i am using is;
System.Diagnost ics.Process.Sta rt("mailto:em.. .@email.com?sub ject=Software&b ody=see attachment&atta chment=c:/myview.mht");
Thanks
try c:\ and prefix the string with an @
ie
(@"mailto:em... @email.com?subj ect=Software&bo dy=see
attachment&atta chment=c:\myvie w.mht"
@ will stop the compiler treating \ as an escape character.- Hide quotedtext -
- Show quoted text -
Ignacio appears to be correct, my apologies. You could always add a
reference to System.Web.Mail and use the classes in there. having a
quick poke, I got:
using System.Web.Mail ;
MailMessage message = new MailMessage();
message.From = "pe****@place.c om";
message.Body = "body";
message.To ="anotherpe**** @place.com";
message.Subject = "subject";
message.Attachm ents.Add(new MailAttachment( @"C:\boot.ini") );
SmtpMail.SmtpSe rver = "smtp.mailserve r.com";
SmtpMail.Send(m essage);
should do it, but if you get a "CDO.messag e not found" message that's
to do with authentication. (I got that error, there seem to be alot of
posts about it!)
alternatively I managed to get this to work using outlook interop, but
again, outlook now has all that cruddy security so it pops up a dialog
saying is this ok?? I'm sure I've read about ways of disabling that,
but it was a while ago.
using Microsoft.Offic e.Interop.Outlo ok;
Microsoft.Offic e.Interop.Outlo ok.Application app =
new Microsoft.Offic e.Interop.Outlo ok.ApplicationC lass();
MailItem message = (MailItem)app.C reateItem(OlIte mType.olMailIte m);
Recipient recip =
(Recipient)mess age.Recipients. Add("pe****@pla ce.com");
recip.Resolve() ;
message.Body = "body";
message.Subject = "subject";
message.Attachm ents.Add(@"C:\b oot.ini",
OlAttachmentTyp e.olByValue,mes sage.Body.Lengt h + 1, "an attachment");
//message.Save();
//message.Display (false);
message.Send();
probably no help, but you never know.