![]() |
If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Search this Thread | Display Modes |
#1
|
|||
|
|||
![]()
I am attempting to set up my Outlook 2007 client to run a rule against
messages with a specific subject that will in turn run a macro to export the body to a local file that will be used for input by Powershell. Here is a copy of the macro I pulled from the web. ' (C) Dmitry Sotnikov ' http://dmitrysotnikov.wordpress.com ' Add this to your Outlook macros project ' Then associate SaveAsText with a rule procesing ' emails from your address with a keyword in subject ' This is to have a Sleep function in Outlook Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) ' The main function saving the script email as text ' and sending back the transcript Sub SaveAsText(MyMail As MailItem) ' Export email (with PowerShell script in body) as a text file MyMail.SaveAs "c:\scripts\outlook.ps1", olTXT ' Create a response email Dim reMail As Outlook.MailItem Set reMail = MyMail.Reply ' wait till transcript is available Set fs = CreateObject("Scripting.FileSystemObject") While Not fs.FileExists("C:\Scripts\email_transcript.txt") Sleep 1000 Wend ' attach the transcript and send it back reMail.Attachments.Add "C:\Scripts\email_transcript.txt" reMail.Send End Sub When this added in the VBA Editor. I can not see this when I attempt to run a macro. If I create a new test macro with out an argument defined with sub. I can see it fine and run the macro all day. Sub HelloWorldMsgBox() MsgBox ("Hello World") End Sub To make this worse. I have no VBA experience so troubleshooting this has been very difficult. When you reply please keep it simple and feel free to talk down to me.... :-) |
Ads |
#2
|
|||
|
|||
![]() That's right, you cannot see it if you want to run a macro. But if you assign it to a run-a-script rule it's visible. -- Best regards Michael Bauer - MVP Outlook : VBOffice Reporter for Data Analysis & Reporting : Outlook Categories? Category Manager Is Your Tool : http://www.vboffice.net/product.html?pub=6&lang=en Am Thu, 24 Jul 2008 13:53:01 -0700 schrieb Ryan: I am attempting to set up my Outlook 2007 client to run a rule against messages with a specific subject that will in turn run a macro to export the body to a local file that will be used for input by Powershell. Here is a copy of the macro I pulled from the web. ' (C) Dmitry Sotnikov ' http://dmitrysotnikov.wordpress.com ' Add this to your Outlook macros project ' Then associate SaveAsText with a rule procesing ' emails from your address with a keyword in subject ' This is to have a Sleep function in Outlook Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) ' The main function saving the script email as text ' and sending back the transcript Sub SaveAsText(MyMail As MailItem) ' Export email (with PowerShell script in body) as a text file MyMail.SaveAs "c:\scripts\outlook.ps1", olTXT ' Create a response email Dim reMail As Outlook.MailItem Set reMail = MyMail.Reply ' wait till transcript is available Set fs = CreateObject("Scripting.FileSystemObject") While Not fs.FileExists("C:\Scripts\email_transcript.txt") Sleep 1000 Wend ' attach the transcript and send it back reMail.Attachments.Add "C:\Scripts\email_transcript.txt" reMail.Send End Sub When this added in the VBA Editor. I can not see this when I attempt to run a macro. If I create a new test macro with out an argument defined with sub. I can see it fine and run the macro all day. Sub HelloWorldMsgBox() MsgBox ("Hello World") End Sub To make this worse. I have no VBA experience so troubleshooting this has been very difficult. When you reply please keep it simple and feel free to talk down to me.... :-) |
#3
|
|||
|
|||
![]()
Michael,
I'm sorry I misspoke. I am creating a macro with a MailItem argument defined. However when I go to create the rule. I can not see it as a macro. When I go to macro - macros. I can not see it. When I am in the editor I can see the code. But not able to run it as the macro pop-up does not show it either. "Michael Bauer [MVP - Outlook]" wrote: That's right, you cannot see it if you want to run a macro. But if you assign it to a run-a-script rule it's visible. -- Best regards Michael Bauer - MVP Outlook : VBOffice Reporter for Data Analysis & Reporting : Outlook Categories? Category Manager Is Your Tool : http://www.vboffice.net/product.html?pub=6&lang=en Am Thu, 24 Jul 2008 13:53:01 -0700 schrieb Ryan: I am attempting to set up my Outlook 2007 client to run a rule against messages with a specific subject that will in turn run a macro to export the body to a local file that will be used for input by Powershell. Here is a copy of the macro I pulled from the web. ' (C) Dmitry Sotnikov ' http://dmitrysotnikov.wordpress.com ' Add this to your Outlook macros project ' Then associate SaveAsText with a rule procesing ' emails from your address with a keyword in subject ' This is to have a Sleep function in Outlook Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) ' The main function saving the script email as text ' and sending back the transcript Sub SaveAsText(MyMail As MailItem) ' Export email (with PowerShell script in body) as a text file MyMail.SaveAs "c:\scripts\outlook.ps1", olTXT ' Create a response email Dim reMail As Outlook.MailItem Set reMail = MyMail.Reply ' wait till transcript is available Set fs = CreateObject("Scripting.FileSystemObject") While Not fs.FileExists("C:\Scripts\email_transcript.txt") Sleep 1000 Wend ' attach the transcript and send it back reMail.Attachments.Add "C:\Scripts\email_transcript.txt" reMail.Send End Sub When this added in the VBA Editor. I can not see this when I attempt to run a macro. If I create a new test macro with out an argument defined with sub. I can see it fine and run the macro all day. Sub HelloWorldMsgBox() MsgBox ("Hello World") End Sub To make this worse. I have no VBA experience so troubleshooting this has been very difficult. When you reply please keep it simple and feel free to talk down to me.... :-) |
#4
|
|||
|
|||
![]() You can see that script only if you're in the rules wizzard. But if you click Tools/Macros/Macros, you cannot see it, that's right. And by the way, in that dialog you couldn't assign any macro to a rule. -- Best regards Michael Bauer - MVP Outlook : VBOffice Reporter for Data Analysis & Reporting : Outlook Categories? Category Manager Is Your Tool : http://www.vboffice.net/product.html?pub=6&lang=en Am Thu, 24 Jul 2008 14:26:04 -0700 schrieb Ryan: Michael, I'm sorry I misspoke. I am creating a macro with a MailItem argument defined. However when I go to create the rule. I can not see it as a macro. When I go to macro - macros. I can not see it. When I am in the editor I can see the code. But not able to run it as the macro pop-up does not show it either. "Michael Bauer [MVP - Outlook]" wrote: That's right, you cannot see it if you want to run a macro. But if you assign it to a run-a-script rule it's visible. -- Best regards Michael Bauer - MVP Outlook : VBOffice Reporter for Data Analysis & Reporting : Outlook Categories? Category Manager Is Your Tool : http://www.vboffice.net/product.html?pub=6&lang=en Am Thu, 24 Jul 2008 13:53:01 -0700 schrieb Ryan: I am attempting to set up my Outlook 2007 client to run a rule against messages with a specific subject that will in turn run a macro to export the body to a local file that will be used for input by Powershell. Here is a copy of the macro I pulled from the web. ' (C) Dmitry Sotnikov ' http://dmitrysotnikov.wordpress.com ' Add this to your Outlook macros project ' Then associate SaveAsText with a rule procesing ' emails from your address with a keyword in subject ' This is to have a Sleep function in Outlook Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) ' The main function saving the script email as text ' and sending back the transcript Sub SaveAsText(MyMail As MailItem) ' Export email (with PowerShell script in body) as a text file MyMail.SaveAs "c:\scripts\outlook.ps1", olTXT ' Create a response email Dim reMail As Outlook.MailItem Set reMail = MyMail.Reply ' wait till transcript is available Set fs = CreateObject("Scripting.FileSystemObject") While Not fs.FileExists("C:\Scripts\email_transcript.txt") Sleep 1000 Wend ' attach the transcript and send it back reMail.Attachments.Add "C:\Scripts\email_transcript.txt" reMail.Send End Sub When this added in the VBA Editor. I can not see this when I attempt to run a macro. If I create a new test macro with out an argument defined with sub. I can see it fine and run the macro all day. Sub HelloWorldMsgBox() MsgBox ("Hello World") End Sub To make this worse. I have no VBA experience so troubleshooting this has been very difficult. When you reply please keep it simple and feel free to talk down to me.... :-) |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Macro to reset a custom defined view for tasks | Phil Rabichow | Outlook and VBA | 4 | March 22nd 08 10:02 PM |
How to design a custom form that use User defined fields defined on a particular folder (not the default inbox one) | Lucas Campos[_2_] | Outlook - Using Forms | 5 | August 17th 07 06:03 PM |
How to retrieve User Defined fields defined in an Folder? | Lucas Campos[_2_] | Outlook - Using Forms | 1 | August 16th 07 10:32 PM |
Outlook macro abends but Word macro runs successfully | Jreue | Outlook and VBA | 0 | December 14th 06 12:55 AM |
outlook macro doesn;t run - sub/function not defined | mudshark | Outlook and VBA | 1 | February 6th 06 11:04 PM |