本文介绍了带附加文件的Mailto弹出窗口.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以编程方式将附件添加到C#和VB.NET中的电子邮件中 [ ^ ]

请参考以上文章.


我为页面设置了AspCompat ="true",然后它适用于我的ASP.NET应用程序.

但是将应用程序托管到服务器[Windows 2003]后,它不起作用.

我们正在其中使用MAPI32.DLL.

Windows 2003中不存在MAPI32.DLL吗?

有什么主意吗?

谢谢

Programmatically adding attachments to emails in C# and VB.NET[^]

Referring to the above article.


I set AspCompat="true" for page, then it working for my ASP.NET application.

But it is not working after hosting the app to server [Windows 2003].

We are using MAPI32.DLL in it.

MAPI32.DLL doesn''t exist in Windows 2003?

Any idea?

Thanks

推荐答案

using System;
using System.Net.Mail;
using System.Net.Mime;

namespace Hugetiger
{

 public class HTSend_eMail
 {

  public void CreateMessageWithAttachment(String server, String pFN)
  {
   Console.WriteLine("\nTop CreateMessageWithAttachment");

   // Create a message and set up the recipients.
   MailMessage message = new MailMessage(
    "[email protected]",  // from
    "[email protected]", // to
    "The C# Letter", // subject
    "See the attached " + pFN);  // body

   // Create  the file attachment for this e-mail message.
   Attachment data = new Attachment(pFN, MediaTypeNames.Application.Octet);
   // Add time stamp information for the file.
   ContentDisposition disposition = data.ContentDisposition;
   disposition.CreationDate = System.IO.File.GetCreationTime(pFN);
   disposition.ModificationDate = System.IO.File.GetLastWriteTime(pFN);
   disposition.ReadDate = System.IO.File.GetLastAccessTime(pFN);
   // Add the file attachment to this e-mail message.
   message.Attachments.Add(data);
   //Send the message.
   SmtpClient client = new SmtpClient(server);
   // Add credentials if the SMTP server requires them.
   client.Credentials = new System.Net.NetworkCredential
      ("[email protected]", "mypassword");

   client.Send(message);
   // Display the values in the ContentDisposition for the attachment.
   /*
   ContentDisposition cd = data.ContentDisposition;
   Console.WriteLine("Content disposition");
   Console.WriteLine(cd.ToString());
   Console.WriteLine("File {0}", cd.FileName);
   Console.WriteLine("Size {0}", cd.Size);
   Console.WriteLine("Creation {0}", cd.CreationDate);
   Console.WriteLine("Modification {0}", cd.ModificationDate);
   Console.WriteLine("Read {0}", cd.ReadDate);
   Console.WriteLine("Inline {0}", cd.Inline);
   Console.WriteLine("Parameters: {0}", cd.Parameters.Count);
   foreach (DictionaryEntry d in cd.Parameters)
   {
    Console.WriteLine("{0} = {1}", d.Key, d.Value);
   }
    * */

   data.Dispose();
   Console.WriteLine("\nBot CreateMessageWithAttachment");

  }

 }
}


这篇关于带附加文件的Mailto弹出窗口.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-01 22:55