benjamin132
New Member
- Joined
- Jun 8, 2022
- Messages
- 21
- Platform
- Windows
Hello everyone,
i need to save and attachment from a mail box named "Autot archiv" on my computer.
2 month ago i create a script that collect data from a email like subject, Title, received time ... but without attachement.
I don't know why this script does not work anymore i have an error " Sub or function undefined".
Do you know why ? and do you know how to collect attachement?
Thanks by advance
i need to save and attachment from a mail box named "Autot archiv" on my computer.
2 month ago i create a script that collect data from a email like subject, Title, received time ... but without attachement.
I don't know why this script does not work anymore i have an error " Sub or function undefined".
Do you know why ? and do you know how to collect attachement?
Thanks by advance
VBA Code:
Sub GetFromOutlook()
Dim OutlookApp As Outlook.Application
Dim OutlookNamespace As Namespace
Dim Folder As MAPIFolder
Dim OutlookMail As Variant
Dim i As Integer
Set OutlookApp = New Outlook.Application
Set OutlookNamespace = OutlookApp.GetNamespace("MAPI")
Set Olinbox = OutlookNamespace.GetDefaultFolder(olFolderInbox)
Set Folder = OutlookNamespace.GetDefaultFolder(olFolderInbox).Folders("Autot")
i = 1
For Each OutlookMail In Folder.Items
Define
Range("C" & Rows.Count).End(xlUp).Offset(1, 0).Value = OutlookMail.Subject
Range("A" & Rows.Count).End(xlUp).Offset(1, 0).Value = OutlookMail.ReceivedTime
Range("B" & Rows.Count).End(xlUp).Offset(1, 0).Value = OutlookMail.Body
i = i + 1
Next OutlookMail
While 0 < Len(Folder)
Folder.Items(1).Move Olinbox.Folders("Autot archiv")
Wend
Set Folder = Nothing
Set OutlookNamespace = Nothing
Set OutlookApp = Nothing
End Sub