在我的一些邮件中,我通过Outlook存储了一些用户属性......
item.UserProperties.Add("CustID", Outlook.OlUserPropertyType.olText)
item.UserProperties("CustID").Value = custID.ToString
在没有安装Outlook的PC(服务器)上,我想将邮件下载为EML并存储用户属性(例如' CustID'等)。
我保存EML的代码:
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim service As New ExchangeService(ExchangeVersion.Exchange2013)
service.Credentials = New WebCredentials("my@email.com", "mypsw")
service.Url = New System.Uri("https://outlook.office365.com/EWS/Exchange.asmx")
Dim entryID As String = "00000000C802F40668D27342B788D508E9210A67005DF9A7DEF7194A418C8515031D4262280000E00005DF9A7DEF7194A418C8515031D4262280002A9D18B320000"
Dim id As New ItemId(Convert(service, "my@email.com", entryID))
Dim email As EmailMessage = EmailMessage.Bind(service, id)
Dim ps As PropertySet = New PropertySet(ItemSchema.MimeContent)
email.Load(ps)
Using fileStream = New IO.FileStream("D:\sandbox\_email_test.eml", IO.FileMode.Create)
fileStream.Write(email.MimeContent.Content, 0, email.MimeContent.Content.Length)
End Using
End Sub
Private Function Convert(service As ExchangeService, mailbox As String, entryID As String) As String
Dim originalID As New AlternateId()
originalID.Format = IdFormat.HexEntryId
originalID.Mailbox = mailbox
originalID.UniqueId = entryID 'EntryId retrieved from email in Outlook
Dim altBase As AlternateIdBase = service.ConvertId(originalID, IdFormat.EwsId)
Dim convertedID As AlternateId = DirectCast(altBase, AlternateId)
Dim strConvertedID As String = convertedID.UniqueId
Return strConvertedID
End Function
有没有办法将用户属性存储在EML中?如果是,如果我双击EML在Outlook中打开它,我可以从EML读回用户属性吗?
谢谢!
答案 0 :(得分:0)
用户属性是Mapi / Extended属性,它们不包含在消息的MimeStream中。如果您将属性添加为X-header,那么它们将在MimeSteam中可用,否则您最好将消息导出为MSG文件,这将使您在所有MAPI属性上完全保真。要导出为MSG,您需要使用Outlook,如果需要自动化,可能会查看兑换http://www.dimastr.com/redemption/rdo_introduction.htm等内容。
干杯 格伦