Форумы HiProg.com - MS ACCESS, VBA, VB

 

Ответить на сообщение

Вернуться к теме

Вы отвечаете на сообщение:

ник: osmor
Письмо представляет из себя объект MailItem у которого есть коллекция Attachments, которая содержит все присоединенные файлы (набор объектов Attachment)
У которого, в свою очередь, есть метод SaveAsFile (путь)вот пример из Help :

Sub SaveAttachment()
    Dim myOlApp As Outlook.Application
    Dim myInspector As Outlook.Inspector
    Dim myItem As Outlook.MailItem
    Dim myAttachments As Outlook.Attachments
    Set myOlApp = CreateObject("Outlook.Application")
    Set myInspector = myOlApp.ActiveInspector
    If Not TypeName(myInspector) = "Nothing" Then
        If TypeName(myInspector.CurrentItem) = "MailItem" Then
            Set myItem = myInspector.CurrentItem
            Set myAttachments = myItem.Attachments
            'Prompt the user for confirmation
            Dim strPrompt As String
            strPrompt = "Are you sure you want to save the first attachment in the current item to the C:\ folder? If a file with the same name already exists in the destination folder, it will be overwritten with this copy of the file."
            If MsgBox(strPrompt, vbYesNo + vbQuestion) = vbYes Then
                myAttachments.Item(1).SaveAsFile "C:\" & _
                myAttachments.Item(1).DisplayName
            End If
        Else
            MsgBox "The item is of the wrong type."
        End If
    End If
End Sub

тут сохраняется только первый влоденный файл, нужно только добавить перебор всей коллекции Attachments


Ваше имя:

Пароль:

Цитировать: [quote][/quote] Код: [code][/code]
Жирный: [b][/b] Наклонный: [i][/i]
URL: [url][/url] 

Сообщение:

 Размер файла не более 50 Кбт. Большие файлы можно размещать на www.slil.ru

Прикрепить:

 

Для вставки смайлов в текст щелкните по значку.