RDCOMClient + Outlook 电子邮件 + 附件文件名
RDCOMClient + Outlook email + Attachment filename
我正在尝试使用 r 中的 RDCOM 客户端获取邮件中附件的名称。
我能够获取主题名称以及正文中的文字
但是我不知道如何获取附件的名称
OutApp <- COMCreate("Outlook.Application")
outlookNameSpace = OutApp$GetNameSpace("MAPI")
folder <- outlookNameSpace$Folders(1)$Folders(1)
emails <- folder$Items
emails(1)[['Subject']] #Gives me name of subject
emails(1)[['body']] # give me text in body of the mail
emails(1)[['attachments']] # Doesn't give me text. It gives me a pointer like
below
An object of class "COMIDispatch"
Slot "ref":
<pointer: 0x0000000008479448>
谁能帮我解决这个问题?
表示指定项目的所有附件的 Attachments property of the MailItem class returns an Attachments 对象。那是合集。
我不熟悉R语法,所以我会在这里粘贴一个C#示例代码:
for (int i = 1; i <= newEmail.Attachments.Count; i++)
{
newEmail.Attachments[i].SaveAsFile(@"C:\TestFileSave\" +
newEmail.Attachments[i].FileName);
}
下面将创建一个向量,其中包含电子邮件中所有附件的名称。
library(RDCOMClient)
OutApp <- COMCreate("Outlook.Application")
outlookNameSpace = OutApp$GetNameSpace("MAPI")
folder <- outlookNameSpace$Folders(1)$Folders(1)
emails <- folder$Items
emails(1)[['Subject']] #Gives me name of subject
emails(1)[['body']] # give me text in body of the mail
attachments.obj <- emails(1)[['attachments']] # Gets the attachment object
attachments <- character() # Create an empty vector for attachment names
if(attachments.obj$Count() > 0){ # Check if there are attachments
for(i in c(1:attachments.obj$Count())){ # Loop through attachments
attachments <- append(attachments, attachments.obj$Item(i)[['DisplayName']]) # Add attachment name to vector
}
}
print(attachments)
我正在尝试使用 r 中的 RDCOM 客户端获取邮件中附件的名称。
我能够获取主题名称以及正文中的文字
但是我不知道如何获取附件的名称
OutApp <- COMCreate("Outlook.Application")
outlookNameSpace = OutApp$GetNameSpace("MAPI")
folder <- outlookNameSpace$Folders(1)$Folders(1)
emails <- folder$Items
emails(1)[['Subject']] #Gives me name of subject
emails(1)[['body']] # give me text in body of the mail
emails(1)[['attachments']] # Doesn't give me text. It gives me a pointer like
below
An object of class "COMIDispatch"
Slot "ref":
<pointer: 0x0000000008479448>
谁能帮我解决这个问题?
表示指定项目的所有附件的 Attachments property of the MailItem class returns an Attachments 对象。那是合集。
我不熟悉R语法,所以我会在这里粘贴一个C#示例代码:
for (int i = 1; i <= newEmail.Attachments.Count; i++)
{
newEmail.Attachments[i].SaveAsFile(@"C:\TestFileSave\" +
newEmail.Attachments[i].FileName);
}
下面将创建一个向量,其中包含电子邮件中所有附件的名称。
library(RDCOMClient)
OutApp <- COMCreate("Outlook.Application")
outlookNameSpace = OutApp$GetNameSpace("MAPI")
folder <- outlookNameSpace$Folders(1)$Folders(1)
emails <- folder$Items
emails(1)[['Subject']] #Gives me name of subject
emails(1)[['body']] # give me text in body of the mail
attachments.obj <- emails(1)[['attachments']] # Gets the attachment object
attachments <- character() # Create an empty vector for attachment names
if(attachments.obj$Count() > 0){ # Check if there are attachments
for(i in c(1:attachments.obj$Count())){ # Loop through attachments
attachments <- append(attachments, attachments.obj$Item(i)[['DisplayName']]) # Add attachment name to vector
}
}
print(attachments)