Nelson78
Well-known Member
- Joined
- Sep 11, 2017
- Messages
- 526
- Office Version
- 2007
Hello everybody.
Every hour I receive a mail from the address example@example.com (no others mail are received from this address).
I need two things:
1) save the attachment in a specified folder (received in csv.7z, saved in xls);
2) trigger a macro from vba Excel that is supposed to elaborate the data in the saved file.
What I've performed until now is what follows (receive the e-mail and alert with a popup).
Reported in ThisOutlookSession:
How can I proceed further?
Every hour I receive a mail from the address example@example.com (no others mail are received from this address).
I need two things:
1) save the attachment in a specified folder (received in csv.7z, saved in xls);
2) trigger a macro from vba Excel that is supposed to elaborate the data in the saved file.
What I've performed until now is what follows (receive the e-mail and alert with a popup).
Reported in ThisOutlookSession:
Code:
Private WithEvents Items As Outlook.Items
Private Sub Application_Startup()
Dim olApp As Outlook.Application
Dim objNS As Outlook.NameSpace
Set olApp = Outlook.Application
Set objNS = olApp.GetNamespace("MAPI")
' default local Inbox
Set Items = objNS.GetDefaultFolder(olFolderInbox).Items
End Sub
Private Sub Items_ItemAdd(ByVal item As Object)
On Error GoTo ErrorHandler
Dim Msg As Outlook.MailItem
If TypeName(item) = "MailItem" Then
Set Msg = item
If item.SenderEmailAddress = "example@example.com" Then MsgBox "MAIL RECEIVED"
End If
ProgramExit:
Exit Sub
ErrorHandler:
MsgBox Err.Number & " - " & Err.Description
Resume ProgramExit
End Sub
How can I proceed further?
Last edited: