Привет! Я хочу написать функцию OnClick для моей кнопки в Ms Acces, которая сохранит вложения из моего электронного письма.
Я нашел этот код, но он работает только как макрос в outlook, а не в access.Я получил эту ошибку «Удаленный сервер не существует или недоступен»
Option Compare Database
Private Sub Polecenie1_Click()
Dim olSelection As Selection
Dim olMail As Object
Dim olAttachments As Attachments
Dim FileCount As Long, i As Long
Dim SaveFolderPath As String
On Error GoTo errHandle
'// Where do you want to save the files?
SaveFolderPath = "d:\odebrane"
Set olSelection = ActiveExplorer.Selection
'----------------------------------------------------
' Extract Attachment(s)
'----------------------------------------------------
'// Here we will iterate each email from our selection
For Each olMail In olSelection
'// making sure it is an actual Outlook mail only
If TypeName(olMail) = "MailItem" Then
Set olAttachments = olMail.Attachments
FileCount = olAttachments.Count
If FileCount > 0 Then
For i = FileCount To 1 Step -1
'// Save file attachments
olAttachments.Item(i).SaveAsFile SaveFolderPath & olAttachments.Item(i).FileName
Next i
End If
Set olAttachments = Nothing
End If
Next olMail
Exit Sub
errHandle:
MsgBox "Error: " & Err.Description, vbExclamation
End Sub