![]() |
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
|
|||
|
|||
![]()
totally new to outlook 2003 and VBA, so please be gentle
yesterday, I added this short piece of code via Tools, Macros, Visual Basic Editor Const ForReading = 1 Const ForWriting = 2 Const ForAppending = 8 Sub CustomMailMessageRule(Item As Outlook.MailItem) logfile = "C:\Temp\email.txt" Set fso = CreateObject("Scripting.FileSystemObject") Set fsOut = fso.OpenTextFile(logfile, ForAppending, True) outputString = "Mail message arrived: " & Item.Subject fsOut.WriteLine outputString fsOut.Close Set fso = Nothing Set fsOut = Nothing End Sub I then created a rule that for each email on this machine, run script which I called Sample1 To my surprise, it worked fine and wrote in append mode a line for each received email. Today, it does not and I can't figure out why it stopped so I removed the rule, removed the code and added it back in (closed and opened OL2003 couple times), but it just won't run any more. What may I have broken? Other than that ![]() |
Ads |
#2
|
|||
|
|||
![]()
a wrote:
totally new to outlook 2003 and VBA, so please be gentle Today, it does not and I can't figure out why it stopped so I removed the rule, removed the code and added it back in (closed and opened OL2003 couple times), but it just won't run any more. What may I have broken? Other than that ![]() try this: Close/Exit OL2003 Start OL2003 Press Alt-F11 which brings up the VBA editor Close the editor It will now work Note that it may start prompting you for allowing it to access userid's and email addresses if you are using Item.SenderName or Item.SenderEmailAddress and I don't know how to make it stop asking, especially if you want the machine to automatically keep writing that information to the file Perhaps someone else knows how to make it stop asking about "how long to allow in minutes" access |
#3
|
|||
|
|||
![]()
Does other VBA code run? If not, check Help | About Microsoft Outlook | Disabled Items.
-- Sue Mosher, Outlook MVP Author of Microsoft Outlook 2007 Programming: Jumpstart for Power Users and Administrators http://www.outlookcode.com/article.aspx?id=54 wrote in message ups.com... totally new to outlook 2003 and VBA, so please be gentle yesterday, I added this short piece of code via Tools, Macros, Visual Basic Editor Const ForReading = 1 Const ForWriting = 2 Const ForAppending = 8 Sub CustomMailMessageRule(Item As Outlook.MailItem) logfile = "C:\Temp\email.txt" Set fso = CreateObject("Scripting.FileSystemObject") Set fsOut = fso.OpenTextFile(logfile, ForAppending, True) outputString = "Mail message arrived: " & Item.Subject fsOut.WriteLine outputString fsOut.Close Set fso = Nothing Set fsOut = Nothing End Sub I then created a rule that for each email on this machine, run script which I called Sample1 To my surprise, it worked fine and wrote in append mode a line for each received email. Today, it does not and I can't figure out why it stopped so I removed the rule, removed the code and added it back in (closed and opened OL2003 couple times), but it just won't run any more. What may I have broken? Other than that ![]() |
#4
|
|||
|
|||
![]()
Sue Mosher wrote:
Does other VBA code run? If not, check Help | About Microsoft Outlook | Disabled Items. there are no disabled items. As Zoe predicted, it runs fine now but I am being prompted every time since I wanted to use the Items.SenderName It's hopeless, can't even have a simple script run in OL2003 ![]() security |
#5
|
|||
|
|||
![]()
SenderName shouldn't raise a prompt if the code is constructed properly. In a "run a script" rule procedure, that means getting the item with the Namespace.GetItemFromID method:
Sub RunAScriptRuleRoutine(MyMail As MailItem) Dim strID As String Dim olNS As Outlook.NameSpace Dim msg As Outlook.MailItem strID = MyMail.EntryID Set olNS = Application.GetNamespace("MAPI") Set msg = olNS.GetItemFromID(strID) ' do stuff with msg, e.g. MsgBox msg.SenderName Set msg = Nothing Set olNS = Nothing End Sub For Outlook VBA basics, see http://outlookcode.com/article.aspx?...tml.htm#ol2002 for another example. -- Sue Mosher, Outlook MVP Author of Microsoft Outlook 2007 Programming: Jumpstart for Power Users and Administrators http://www.outlookcode.com/article.aspx?id=54 wrote in message s.com... Sue Mosher wrote: Does other VBA code run? If not, check Help | About Microsoft Outlook | Disabled Items. there are no disabled items. As Zoe predicted, it runs fine now but I am being prompted every time since I wanted to use the Items.SenderName It's hopeless, can't even have a simple script run in OL2003 ![]() security |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
.ics file attachment being received as plain text message by outlook | [email protected] | Outlook - Calandaring | 1 | September 25th 07 03:24 AM |
Outlook 2003 - contact list not showing up when writing new email | Carol M | Outlook - Using Contacts | 1 | July 14th 07 03:14 AM |
I cannot open a URL in a received email message in Outlook 2003 | Paul Mayer | Outlook - General Queries | 1 | July 11th 07 08:00 PM |
I received the message"this file can | Minneapois | Outlook - Calandaring | 0 | October 30th 06 06:06 PM |
writing email get word error message interface not supported | Erik R | Outlook - General Queries | 2 | October 12th 06 07:28 PM |