1
我正在編寫一個程序,我的主管要我利用他們的內部沙箱電子郵件系統。c#使用POST和Mime發送電子郵件
從本質上講,我到目前爲止的代碼是:
WebRequest request = WebRequest.Create(uri);
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
Stream os = null;
byte[] Bytes = Encoding.ASCII.GetBytes("From: [email protected]\n" + "To: [email protected]\n" + "Subject: test\n" + "jkjlkjkj\n");
try
{
request.ContentLength = Bytes.Length;
os = request.GetRequestStream();
os.Write(Bytes, 0, Bytes.Length);
}
catch (Exception e)
{
Console.WriteLine("error");
}
這工作正常,併發送電子郵件的預期。但是我怎樣才能使用這種方法發送附件?他們可能會打開小型轉儲文件。
謝謝。
這很大程度上取決於系統如何對附件進行格式化。 `WebRequest`僅用於發送HTTP請求。 – 2010-12-03 13:06:28