Send outlook attachment to Sharepoint list

喜你入骨 提交于 2021-01-28 05:38:30

问题


We are working on a small VBA code that transmits the content of an e-mail message in Outlook to SharePoint. Our code reads the e-mail and filters out some key components (which are stored in variables). We then use ADODB to create a new item in a SharePoint list.

For that we use the following code:

Dim cnt As ADODB.Connection
Dim rst As ADODB.Recordset
Dim mySQL As String

Set cnt = New ADODB.Connection
Set rst = New ADODB.Recordset

mySQL = "SELECT * FROM [xxxx];"

With cnt
    .ConnectionString = _
    "Provider=Microsoft.ACE.OLEDB.12.0;WSS;IMEX=0;RetrieveIds=Yes;DATABASE=xxxxxx;LIST={xxxxx};"
    .Open
End With

rst.Open mySQL, cnt, adOpenDynamic, adLockOptimistic

rst.AddNew
    rst.Fields("Titel") = TheName
    rst.Fields("ValidFrom") = ValidFrom
    rst.Fields("ValidUntil") = ValidUntil
    rst.Fields("VersionNr") = Version
rst.Update


If CBool(rst.State And adStateOpen) = True Then rst.Close
Set rst = Nothing
If CBool(cnt.State And adStateOpen) = True Then cnt.Close
Set cnt = Nothing

However, we want to send the attachment of the e-mail (if there is an attachment) also to the sharepoint list, and we are at a loss how to achieve this. After some Googling we found that it is possible to upload the file to a document library, and then use a hyperlink in the sharepoint list to that document. But for us it is possible to have multiple files in one e-mail... Does somebody know a way to achieve this?

来源:https://stackoverflow.com/questions/54255570/send-outlook-attachment-to-sharepoint-list

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!