Getting Attachments from Unread Emails in Outlook

MaliciousMike

Registered User.
Local time
Today, 14:53
Joined
May 24, 2006
Messages
118
Afternoon,

I'm setting up an email addy which clients can send data to.
I want to write a bit of code that will take attachments off any unread emails, validate them, and send replies depending on the outcome (this needs to reply to the original email).

Also, depending on the outcome i would love to organise the emails in the inbox all via VB.

I'm not new to VB coding, but i've never touched outlook like this before.

I've found this little bit of code which is a great help, but i need a little help in editing it:

Code:
Public Sub ReadInbox()
Dim OlApp As Outlook.Application
Dim Inbox As Outlook.MAPIFolder
Dim InboxItems As Outlook.Items
Dim Mailobject As Object

' Let's connect to Outlook
Set OlApp = CreateObject("Outlook.Application")
Set Inbox = OlApp.GetNamespace("Mapi").GetDefaultFolder(olFolderInbox)

Set InboxItems = Inbox.Items

'For each email in the inbox
For Each Mailobject In InboxItems
    'If the email is unread...
    If Mailobject.UnRead Then
    
    ...........

    End If
Next


'CleanUp
Set OlApp = Nothing
Set Inbox = Nothing
Set InboxItems = Nothing
Set Mailobject = Nothing

End Sub

Where the ....... is where i need to add:
Get and Save attachment
run a sub on it
If Sub is true: reply saying "yay", move email to "success" folder
Else, reply saying "nay - here's why", move to "rejected" folder

I can do the majority of the above, it's dealing with the attachments and Replying to the emails which i need help with. Also with moving them into other folders.

Thanks to anyone that can help.
 

Users who are viewing this thread

Back
Top Bottom