我正在尝试从辅助角色(Azure)发送一封带有附件(来自 blob 存储)的电子邮件(在 c# 中)。我可以发送电子邮件,但附件(word 文档)为空白。从工作角色调用以下函数。
public void sendMail(string blobName)
{
InitStorage();//Initialize the storage
var storageAccount = CloudStorageAccount.FromConfigurationSetting("DataConnectionString");
container = blobStorage.GetContainerReference("Container Name");
CloudBlockBlob blob = container.GetBlockBlobReference(blobName);
if (File.Exists("demo.doc"))
File.Delete("demo.doc");
FileStream fs = new FileStream("demo.doc", FileMode.OpenOrCreate);
blob.DownloadToStream(fs);
Attachment attach = new Attachment(fs,"Report.doc");
System.Net.Mail.MailMessage Email = new System.Net.Mail.MailMessage("User@hotmail.com", "User@gmail.com");
Email.Subject = "Text fax send via email";
Email.Subject = "Subject Of email";
Email.Attachments.Add(attach);
Email.Body = "Body of email";
System.Net.Mail.SmtpClient client = new SmtpClient("smtp.live.com", 25);
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.EnableSsl = true;
client.Credentials = new NetworkCredential("User@hotmail.com", Password);
client.Send(Email);
fs.Flush();
fs.Close();
Email.Dispose();
}
请告诉我我做错了什么?