Quantcast
Channel: Microsoft Exchange
Viewing all articles
Browse latest Browse all 20055

Outlook 2010 VBA Review & Help

$
0
0

Hi All

I've been given the task of writing some code, that when an email is received in outlook, it is automatically copied to a directory for our document system to process. I have hacked some code I found from stackoverflow and come up with the below.

The code only works when I open the email and manually run it, I'm not too sure what to change/create to make it work?


Sub SaveToDMS()

Dim myItem As Outlook.Inspector
Dim objItem As Object
Dim strname As String


Set myItem = Application.ActiveInspector
If Not TypeName(myItem) = "Nothing" Then
Set objItem = myItem.CurrentItem

strname = "u:\dms" & Format(objItem.SentOn, "dd-MM-yyyy hh-mm") & " From " & objItem.SenderName & " To " & objItem.To & ".msg"

objItem.SaveAs strname, olMSGUnicode
End If
End Sub


Viewing all articles
Browse latest Browse all 20055

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>