使用RDCOMClient通过Outlook中的Outlook发送电子邮件附件 [英] Sending Email Attachement Through Outlook in R with RDCOMClient
问题描述
库(RDCOMClient)
pre>
OutApp< - COMCreate(Outlook.Application)
outMail = OutApp $ CreateItem(0)
outMail [[to]] =gkinne@horizonmedia.com
outMail [[subject]] =Bruh
outMail [[body]] =Tester
outMail [[附件]] $ Add(L:/Document.csv)
outMail $ Send()
原来是在这里:
代码工作,直到附件部分,电子邮件甚至发送,只是没有附件。它出现这个错误:
< checkErrorInfo> 80020009
不支持InterfaceSupportsErrorInfo
checkErrorInfo -2147352567
错误:发生异常。
任何想法?
解决方案反斜杠并转义它们。
问题是在R中创建路径,正斜杠(由于反斜杠是转义字符),而是由Outlook解释,后者只能使用反斜杠。
例如,尝试通过将路径粘贴到插入文件对话框中,将附件附加到Outlook电子邮件,但将反斜杠更改为正斜杠。它不接受它。这实际上是你想要做的。
所以反过来使它们成为反斜杠,然后为每个反斜杠添加额外的反斜杠来转义它们。例如:
C:\\Users\\MyFiles\\Documents\\document。 txt
R将删除转义字符,并将干净的路径传递给Outlook。
I'm Running a daily analysis that spits out a file I would like sent through my outlook Email. The code I used is featured here, and works wonderfully but the attachment part of it never works...
library(RDCOMClient) OutApp <- COMCreate("Outlook.Application") outMail = OutApp$CreateItem(0) outMail[["To"]] = "gkinne@horizonmedia.com" outMail[["subject"]] = "Bruh" outMail[["body"]] = "Tester" outMail[["Attachments"]]$Add("L:/Document.csv") outMail$Send()
The original is here:
Sending email in R via outlook
The code works until the attachment part, and the email even sends, just with no Attachment. It spits this error out:
<checkErrorInfo> 80020009 No support for InterfaceSupportsErrorInfo checkErrorInfo -2147352567 Error: Exception occurred.
Any Ideas?
解决方案Reverse the slashes and escape them.
The problem is that the path is being created in R, which prefers forward slashes (since the backslash is the escape character), but it's being interpreted by Outlook, which only takes backslashes.
For example, try adding an attachment to an Outlook email by pasting a path into the insert file dialogue, but change the backslashes to forward slashes. It doesn't accept it. And that's essentially what you're trying to do.
So reverse to make them backslashes, then add extra backslashes to each one to escape them. For example:
C:\\Users\\MyFiles\\Documents\\document.txt
R will strip out the escape characters and and pass a clean path to Outlook.
这篇关于使用RDCOMClient通过Outlook中的Outlook发送电子邮件附件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!