Re: System.Web.Mail to send out email from desktop app



I solved the problem.

Warning: It is very convoluted.

First,

//not good (but good in ASP.NET)
SmtpMail.SmtpServer = "mail.myserver.com";

//good (don't ask me why)
SmtpMail.SmtpServer.Insert(0, "mail.myserver.com");

Issues with attachments

//Not good (note the relative path)
mail.Attachments.Add(new MailAttachment(@"deathtomicrosoft.txt"));

//good (note the absolute path)
mail.Attachments.Add(new MailAttachment(@"C:\Documents and
Settings\David.SHADOWFAX\My Documents\Visual Studio
Projects\MyProject\bin\Debug\Temp"));

The attachment thing is interesting. When you specify the relative
path, the code does not crash. When you give it a bad file name, it
crashes. So using relative paths SEEMS okay, until you do
SmtpMail.Send.

*** Sent via Developersdex http://www.developersdex.com ***
.



Relevant Pages

  • Re: How does Require deal with multiple files of the same name in different directories
    ... include would fail anyway) a check could be made for any file and if ... one exists assume it's correct (pssibly issuing a warning). ... A relative path is specified and more than one path in the paths ... the loaded file isn't in the search path (probably as a result of ...
    (comp.lang.forth)
  • RE: [Full-Disclosure] Avoiding being a good admin - was DCOM RPC exploit (dcom.c)
    ... warning of impending doom and being proved right when no-one takes ... The information contained in this email and any attachments is ... RNIB has made strenuous efforts to ensure that emails and any ...
    (Full-Disclosure)
  • {Filename?} Returned mail: see transcript for details
    ... This message has had one or more attachments removed ... Warning:. ... This is a message from the MailScanner E-Mail Virus Protection Service ... The original e-mail attachment "attachment.scr" ...
    (comp.lang.python)
  • Re: Your application
    ... This message has had one or more attachments removed ... Warning:. ... The original e-mail attachment "movie0045.pif" ... Shortcuts to MS-Dos programs are very dangerous in email ...
    (comp.sys.sgi.misc)
  • Re: Microsoft is NOT sending ANY emails to you. Read this!
    ... Express doesn't know--it is simply warning you of that fact. ... > one go thru loops and hoops by giving false signals. ... >>Your attachments are still there, and you can turn it off ... >>the safe ones, and then turn it on again. ...
    (microsoft.public.security.virus)