调用外部文件是什么意思?最简单的发邮件的代码:
Example
The following example can be compiled to a console application that is used to send email from a command line. If you compile the example to a file named MailMessage.exe, use the executable file to send email as follows:MailMessage [email protected] [email protected] test hello using System;
using System.Web.Mail;
 
namespace SendMail
{
   class usage
   {
      public void DisplayUsage()
      {
         Console.WriteLine("Usage SendMail.exe <to> <from> <subject> <body>");
         Console.WriteLine("<to> the addresses of the email recipients");
         Console.WriteLine("<from> your email address");
         Console.WriteLine("<subject> subject of your email");
         Console.WriteLine("<body> the text of the email");
         Console.WriteLine("Example:");
         Console.WriteLine("SendMail.exe [email protected];[email protected] [email protected] Hi hello");
      }
   }
    class Start
   {
      // The main entry point for the application.
      [STAThread]
      static void Main(string[] args)
      {
         try
         {
            try
            {
               MailMessage Message = new MailMessage();
               Message.To = args[0];
               Message.From = args[1];
               Message.Subject = args[2];
               Message.Body = args[3];               try
               {
                  SmtpMail.SmtpServer = "your mail server name goes here";
                  SmtpMail.Send(Message);
               }
               catch(System.Web.HttpException ehttp)
               {
                  Console.WriteLine("{0}", ehttp.Message);
                  Console.WriteLine("Here is the full error message output");
                  Console.Write("{0}", ehttp.ToString());
               }
            }
            catch(IndexOutOfRangeException)
            {
               usage use = new usage();
               use.DisplayUsage();
            }
         }
         catch(System.Exception e)
         {
            Console.WriteLine("Unknown Exception occurred {0}", e.Message);
            Console.WriteLine("Here is the Full Message output");
            Console.WriteLine("{0}", e.ToString());
         }
      }
   }
}

解决方案 »

  1.   

    如果需要带有附件的话,加一句:
    Message.Attachments.Add(new MailAttachment(filePath,MailEncoding.Base64))这样如果你的IIS装了SMTP,那就可以发送邮件了
    或者指定一个SMTP Server(不用认证的才可以)
    SmtpMail.SmtpServer = "mail.xxx.com";
      

  2.   

    就是用smtp就可以了,为什么还要调用外部程序?
      

  3.   

    不用那么麻烦吧,你可以调用系统默认的邮件程序,比如说outlook或者FoxMail,只要象下面这样就行了。System.Diagnostics.Process.Start( "mailto:[email protected]" );默认的是哪个程序就调用啊个。
      

  4.   

    这种关键字很明确的问题,最好自己到google上搜索。
      

  5.   

    同意cherishl(老郎) 的看法,用
    System.Diagnostics.Process.Start( "mailto:[email protected]" );