On 4 Jan, 13:59, JimJob <Jim...@discussions.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...@discussions.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.Diagnostics.Process.Start("mailto:em...@ema il.com?subject=Software&body=see attachment&attachment=c:/myview.mht");
Thanks
try c:\ and prefix the string with an @
ie
(@"mailto:em...@email.com?subject=Software&body=se e
attachment&attachment=c:\myview.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.com";
message.Body = "body";
message.To ="anotherpe****@place.com";
message.Subject = "subject";
message.Attachments.Add(new MailAttachment(@"C:\boot.ini"));
SmtpMail.SmtpServer = "smtp.mailserver.com";
SmtpMail.Send(message);
should do it, but if you get a "CDO.message 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.Office.Interop.Outlook;
Microsoft.Office.Interop.Outlook.Application app =
new Microsoft.Office.Interop.Outlook.ApplicationClass( );
MailItem message = (MailItem)app.CreateItem(OlItemType.olMailItem);
Recipient recip =
(Recipient)message.Recipients.Add("pe****@place.co m");
recip.Resolve();
message.Body = "body";
message.Subject = "subject";
message.Attachments.Add(@"C:\boot.ini",
OlAttachmentType.olByValue,message.Body.Length + 1, "an attachment");
//message.Save();
//message.Display(false);
message.Send();
probably no help, but you never know.