0
我想壓縮收到的電子郵件之前,它被附加到另一封電子郵件。所以我堅持使用zip部分。我試圖壓縮的對象是一個COM對象,不支持序列化。任何可以幫助我進步的想法都是值得歡迎的!VSTO Outlook加載項:郵編COM對象
而且到目前爲止的代碼(selObject是COM對象):
private void Report_Malicious_Email_Click(object sender, RibbonControlEventArgs e)
{
// selObject este mailul selectat
Object selObject = this.Application.ActiveExplorer().Selection[1];
if (selObject is Outlook.MailItem) // de aici incepe logica pentru forward cu atasament!
{
using (MemoryStream msCompressed = new MemoryStream())
using (GZipStream gZipStream = new GZipStream(msCompressed, CompressionMode.Compress))
using (MemoryStream msDecompressed = new MemoryStream())
{
new BinaryFormatter().Serialize(msDecompressed, selObject);
byte[] byteArray = msDecompressed.ToArray();
gZipStream.Write(byteArray, 0, byteArray.Length);
gZipStream.Close();
msCompressed.ToArray();
}
Outlook.MailItem eMail =
(Outlook.MailItem)this.Application.CreateItem(Outlook.OlItemType.olMailItem);
eMail.Subject = subjectEmail;
eMail.To = toEmail;
eMail.Body = bodyEmail;
eMail.Attachments.Add(selObject);
eMail.Send();
}
}