Detect Google Drive and OneDrive links in incoming mail

gruiz

New Member
Outlook version
Outlook 2016 32 bit
Email Account
Exchange Server
Hello everyone! Security policies don't let me open Google Drive and OneDrive links at work, although I can see them on the email (don't ask... can't change that).

How can I detect this incoming emails to warn the sender that I didn't got his attached files? They believe the files arrived safe because no email is bounced and in fact the email arrived safely but not the attached files.

I can do that manually looking at each email but its a time consuming task. I saw that Google Drive shows as links that contains "drive.google" somewhere in the html and OneDrive are small files with .drv extension.

I would like to use VBA in Outlook to automatically send a reply with some predefined text replying that I didn't get those files and they must be sent as an attachment

Thanks!
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
You can use a run a script rule or itemadd macro - i'd probably use instr function and look for keywords in the body

Code:
strbody = item.body
if instr(1,strbody, "drive.google") > 0 or if instr(1,strbody, ".drv") > 0 then
'send reply
end if
This page has a sample macro for sending the reply
 

gruiz

New Member
Outlook version
Outlook 2016 32 bit
Email Account
Exchange Server
Thanks Diane! I'll further investigate since I need to apply it to emails already received. I'm using Access VBA from quite a long time, but Outlook's is a little bit different.

It seems that I would be some time reading all Outlook related things at slipstick.com to achieve what I want.

Is there any reading you can recommend me to get in touch with the Outlook VBA object model? Reading MS documentation right now but I mean real examples and not just properties and methods.

Thanks again!
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
Outlookcode.com had a lot of information but it's been offline for a while now.

Do you want to always run it yourself on selected messages? It's not difficult to change a run a script rule to manual - or to use both.

Use a 'stub macro' to trigger the script or replace 'YourMacroName objItem' with the code that does what you need. You need to make sure the object names match up - which you should know from Access VBA.

Code:
Sub RunScript()
Dim objApp As Outlook.Application
Dim objItem As Object ' MailItem
Set objApp = Application
Set objItem = objApp.ActiveExplorer.Selection.Item(1)

'macro name you want to run goes here
YourMacroName objItem

End Sub
 
Top