Re: Outlook Macros
"Michael Sole" <[email protected]>
| Newsgroups | gmane.mail.spam.crm114 |
|---|---|
| Message-ID | <[email protected]> |
Actually I just realized this does not forward as an attachment. Can someone help me modify this so it does? From: crm114-general-bounces-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org [mailto:crm114-general-bounces-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org] On Behalf Of Michael Sole Sent: Thursday, July 10, 2008 9:44 AM To: [email protected] Subject: [Crm114-general] Outlook Macros Hi, I just found this piece of code and it worked in Outlook 2007 straight away, pretty sure it should work in 2000/2003/XP as well. I just created 2 toolbar buttons for good and bad mail. You just need to modify it to use your email address and training command . Function GetCurrentItem() As Object Dim objApp As Outlook.Application Set objApp = CreateObject("Outlook.Application") On Error Resume Next Select Case TypeName(objApp.ActiveWindow) Case "Explorer" Set GetCurrentItem = objApp.ActiveExplorer.Selection.Item(1) Case "Inspector" Set GetCurrentItem = objApp.ActiveInspector.CurrentItem Case Else ' anything else will result in an error, which is ' why we have the error handler above End Select Set objApp = Nothing End Function Sub ADDASGOOD() Dim myOlApp As New Outlook.Application Dim myItem, myForward As Object Set myItem = GetCurrentItem() Set myForward = myItem.Forward myForward.To = "TRAINING EMAIL HERE" 'The line below will place the sent item directly in Deleted Items saving the need to delete it afterwards Set myForward.SaveSentMessageFolder = Application.GetNamespace("MAPI").GetDefaultFolder(olFolderDeletedItems) 'The line below will add your text to the beginning of the message body. myForward.Body = " TRAINING COMMAND HERE (GOOD)" & vbCrLf & myForward.Body 'The line below sends the message. myForward.Send Set myItem = Nothing Set myForward = Nothing End Sub Sub ADDASSPAM() Dim myOlApp As New Outlook.Application Dim myItem, myForward As Object Set myItem = GetCurrentItem() Set myForward = myItem.Forward myForward.To = "TRAINING EMAIL HERE" 'The line below will place the sent item directly in Deleted Items saving the need to delete it afterwards Set myForward.SaveSentMessageFolder = Application.GetNamespace("MAPI").GetDefaultFolder(olFolderDeletedItems) 'The line below will add your text to the beginning of the message body. myForward.Body = "TRAINING COMMAN HERE (BAD)" & vbCrLf & myForward.Body 'The line below sends the message. myForward.Send Set myItem = Nothing Set myForward = Nothing End Sub Perhaps someone would like to post it on the Wiki. I was looking for this for a while. Michael ------------------------------------------------------------------------- Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW! Studies have shown that voting for your favorite open source project, along with a healthy diet, reduces your potential for chronic lameness and boredom. Vote Now at http://www.sourceforge.net/community/cca08 _______________________________________________ Crm114-general mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/crm114-general