MS Outlook VBA通​​过身份验证将电子邮件附件上传到Sharepoint [英] MS Outlook VBA to upload email attachment to a Sharepoint with authentication

查看:90
本文介绍了MS Outlook VBA通​​过身份验证将电子邮件附件上传到Sharepoint的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我还是使用VBA的初学者,并且我一直在尝试找出如何通过MS Outlook中的VBA将文件上传到Sharepoint的方法.我尝试将Sharepoint映射到我的网络驱动器等,但无济于事.

I'm still sort of a beginner in using VBA and I've been trying to figure out how to upload a file via VBA in MS Outlook to a Sharepoint. I've tried mapping the Sharepoint to my Network Drive and such but to no avail.

我的代码如下:

Public Sub saveAttachSentDate(MItem As Outlook.MailItem)

Dim oAttachment As Outlook.Attachment
Dim sSaveFolder As String
Dim file As String
Dim DateFormat As String

sSaveFolder = "(URL of the sharepoint along with the folder to save it on)"


For Each oAttachment In MItem.Attachments
DateFormat = Format(MItem.SentOn - 1, "mm.dd.yy ")
file = sSaveFolder & DateFormat & oAttachment.DisplayName
oAttachment.SaveAsFile sSaveFolder & DateFormat & oAttachment.DisplayName
Next

End Sub

我的文件名"的标签如下:"[我的部门]-(客户名)电话摘要"

My File Name is labelled like this: "[My Department] - (Client Name) Telephony Summary"

我总是会收到此错误

运行时错误'2147024735(800700a1)':无法保存附件.文件名或目录名无效."

我认为可能的原因是,我上载到的共享点每次访问都需要用户名和密码.我使用不需要登录凭据的完全相同的代码尝试了另一个共享点,并且工作正常.我似乎找不到解决方法,不胜感激!

I'm thinking that the probable cause is that the sharepoint I'm uploading to requires a username and password every time you access it. I tried another sharepoint using the same exact code that doesn't require login credentials and it works just fine. I can't seem to find a work-around and I'd appreciate any help!

推荐答案

传递给演练:为Outlook创建第一个VSTO加载项,以快速入门.

The path passed to the SaveAsFile method can't be represented by the URL string or network location. You need to specify a local folder from which you can start uploading files. The Outlook object model doesn't provide anything for uploading files to any web servers, so you will have to do that on your own. To get that working I'd recommend developing a COM add-in. For example, VSTO based add-ins are built on top of .net framework and can use BCL classes to deal with that. See Walkthrough: Create your first VSTO Add-in for Outlook to get started quickly.

这篇关于MS Outlook VBA通​​过身份验证将电子邮件附件上传到Sharepoint的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆