英文:
Get the Email-Adress out of an Email from Outlook
问题
我尝试从Outlook的电子邮件中获取电子邮件地址。我可以获取电子邮件,但当我尝试从同一Exchange发送的电子邮件中获取电子邮件地址时,我得到了一个奇怪的字符串,但我该如何只获取电子邮件地址。
/O=EXCHANGELABS/OU=EXCHANGE ADMINISTRATIVE GROUP (FYDIBOHF23SPDLT)/CN=RECIPIENTS/CN=FIRMA.ONMICROSOFT.COM-50609-MAX.MUSTERMANN@FIRMA.COM91C
这是我获取电子邮件地址的代码。
private List<OutlookEmailObject> DecodeOutlookEmail(IDataObject data)
{
XPressSideBoardLogger.Log("DecodeOutlookEmail()", true, ServiceLogger.LoggerMode.Verbose);
List<OutlookEmailObject> outlookEmailObjects = new List<OutlookEmailObject>();
OutlookDataObject dataObject = new OutlookDataObject(data);
string[] filenames = (string[])dataObject.GetData("FileGroupDescriptorW");
List<string> tempfiles = new List<string>();
MemoryStream[] filestreams = (MemoryStream[])dataObject.GetData("FileContents");
int memoryStreamIndex = 0;
foreach (string s in filenames)
{
MemoryStream filestream = filestreams[memoryStreamIndex];
tempfiles.Add(Path.GetTempPath() + s);
FileStream outputStream = File.Create(Path.GetTempPath() + s);
filestream.WriteTo(outputStream);
outputStream.Close();
memoryStreamIndex++;
}
foreach (string s in tempfiles)
{
using (Storage.Message msg = new Storage.Message(s))
{
if (!_outlookDropInSearchbar)
AssignCategories(msg.Subject, msg.Sender.Email, msg.BodyText);
// 其他处理代码...
}
}
// 其他处理代码...
}
希望这能帮助你获取电子邮件地址。
英文:
i'm trying to get the Email-Address out of an Email from Outlook. I get the Email, only when i'm trying to get the Email-Adress out of an Email witch was send from the same Excanche, i get a weird String but how can i get only the Email-Adress out of it.
/O=EXCHANGELABS/OU=EXCHANGE ADMINISTRATIVE GROUP (FYDIBOHF23SPDLT)/CN=RECIPIENTS/CN=FIRMA.ONMICROSOFT.COM-50609-MAX.MUSTERMANN@FIRMA.COM91C
Thats the Code where i get the Email-Address
private List<OutlookEmailObject> DecodeOutlookEmail(IDataObject data)
{
XPressSideBoardLogger.Log($"DecodeOutlookEmail()", true, ServiceLogger.LoggerMode.Verbose);
List<OutlookEmailObject> outlookEmailObjects = new List<OutlookEmailObject>();
OutlookDataObject dataObject = new OutlookDataObject(data);
string[] filenames = (string[])dataObject.GetData("FileGroupDescriptorW");
List<string> tempfiles = new List<string>();
MemoryStream[] filestreams = (MemoryStream[])dataObject.GetData("FileContents");
int memoryStreamIndex = 0;
foreach (string s in filenames)
{
MemoryStream filestream = filestreams[memoryStreamIndex];
tempfiles.Add(Path.GetTempPath() + s);
FileStream outputStream = File.Create(Path.GetTempPath() + s);
filestream.WriteTo(outputStream);
outputStream.Close();
memoryStreamIndex++;
}
foreach (string s in tempfiles)
{
using (Storage.Message msg = new Storage.Message(s))
{
if (!_outlookDropInSearchbar)
AssignCategories(msg.Subject, msg.Sender.Email, msg.BodyText);
...
答案1
得分: 0
这似乎是一个完全有效的地址,类型为“EX”(而不是“SMTP”)。
您需要读取MAPI属性PidTagSenderSmtpAddress
(DASL名称为http://schemas.microsoft.com/mapi/proptag/0x5D01001F
),或者如果该属性不可用,则从发件人GAL对象中检索SMTP地址(在Outlook对象模型中为MailItem.Sender.GetExchangeUser().PrimarySmtpAddress
)。
我不知道Storage.Message
是什么以及是否允许检索任意MAPI属性,但您可以仅使用Outlook对象模型 - 因为消息在从Outlook中拖出之前需要首先选择,所以您可以简单地使用Application.ActiveExplorer.Selection
集合。
英文:
That looks like a perfectly valid address of type EX
(as opposed to SMTP
).
You need to read PidTagSenderSmtpAddress
MAPI property (DASL name is http://schemas.microsoft.com/mapi/proptag/0x5D01001F
) or, if the property is not available, retrieve the SMTP address from from the sender GAL object (MailItem.Sender.GetExchangeUser().PrimarySmtpAddress
in Outlook Object Model).
I do not know what Storage.Message
is and whether it allows to retrieve arbitrary MAPI proprieties, but your can get away with using just the Outlook Object Model - since the message needs to be selected first before it can be dragged out of Outlook, you can simply use the Application.ActiveExplorer.Selection
collection.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论