{"id":56153,"date":"2008-02-21T23:12:00","date_gmt":"2008-02-21T23:12:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2008\/02\/21\/hey-scripting-guy-how-can-i-set-a-reminder-on-all-my-office-outlook-appointments\/"},"modified":"2008-02-21T23:12:00","modified_gmt":"2008-02-21T23:12:00","slug":"hey-scripting-guy-how-can-i-set-a-reminder-on-all-my-office-outlook-appointments","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/hey-scripting-guy-how-can-i-set-a-reminder-on-all-my-office-outlook-appointments\/","title":{"rendered":"Hey, Scripting Guy! How Can I Set a Reminder on All My Office Outlook Appointments?"},"content":{"rendered":"<p><img decoding=\"async\" height=\"34\" width=\"34\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/q-for-powertip.jpg\" align=\"left\" alt=\"Hey, Scripting Guy! Question\" border=\"0\" title=\"Hey, Scripting Guy! Question\" class=\"nearGraphic\" \/><\/p>\n<p>Hey, Scripting Guy! My manager does not like appointment reminders; therefore every meeting request she sends is without reminders.&nbsp; I like reminders and I try to remember to turn them on, but sometimes I forget; that means that if I&#8217;m not on top of my schedule, I can miss a meeting.&nbsp;How can I write a script that will go through all my meetings and appointments and add a reminder to them?<\/p>\n<p>&#8212; PS<\/p>\n<p><img decoding=\"async\" height=\"5\" width=\"5\" src=\"https:\/\/devblogs.microsoft.com\/scripting\/wp-content\/uploads\/sites\/29\/2019\/05\/spacer.gif\" alt=\"Spacer\" border=\"0\" \/><img decoding=\"async\" height=\"34\" width=\"34\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/a-for-powertip.jpg\" align=\"left\" alt=\"Hey, Scripting Guy! Answer\" border=\"0\" title=\"Hey, Scripting Guy! Answer\" class=\"nearGraphic\" \/><a href=\"http:\/\/go.microsoft.com\/fwlink\/?linkid=68779&amp;clcid=0x409\"><img decoding=\"async\" height=\"288\" width=\"120\" src=\"http:\/\/img.microsoft.com\/library\/media\/1033\/technet\/images\/scriptcenter\/ad.jpg\" align=\"right\" alt=\"Script Center\" border=\"0\" title=\"Script Center\" class=\"farGraphic\" \/><\/a><\/p>\n<p>Hey, PS. Well, today is Thursday. Or so we think; to tell you the truth, after you&rsquo;ve stayed up till the wee hours of the morning several nights in a row, well, at some point the days all kind of meld together. <\/p>\n<p>And yes, that includes the weekends, too. How do the Scripting Guys plan to spend their time off this coming weekend? The same way most people plan to spend their time off this coming weekend: testing hundreds and hundreds of Perl, VBScript, and Windows PowerShell scripts, scripts submitted as part of the on-going <a href=\"http:\/\/www.microsoft.com\/technet\/scriptcenter\/funzone\/games\/default.mspx\"><b>2008 Winter Scripting Games<\/b><\/a>. (The Games run until March 3<sup>rd<\/sup>, which means there&rsquo;s sill plenty of time to have some fun and maybe <a href=\"http:\/\/www.microsoft.com\/technet\/scriptcenter\/funzone\/games\/games08\/prizes.mspx\"><b>win yourself a ton of great prizes<\/b><\/a>.)<\/p>\n<table cellpadding=\"0\" cellspacing=\"0\" class=\"dataTable\" id=\"EMD\">\n<thead><\/thead>\n<tbody>\n<tr valign=\"top\" class=\"record\">\n<td>\n<p class=\"lastInCell\"><b>Note<\/b>. Limit of one per person. That means one prize, not one ton.<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<div class=\"dataTableBottomMargin\"><\/div>\n<p>Interesting enough, the Scripting Son refers to his father and his colleagues as &ldquo;nerds.&rdquo; <i>Nerds<\/i>?!? The Scripting Guys are definitely <i>not<\/i> nerds; after all, no self-respecting nerd would spend an entire weekend testing hundreds and hundreds of Perl, VBScript, and Windows PowerShell scripts.<\/p>\n<p>But do you know what the best thing is about the Scripting Games? (And no, believe it or not it&rsquo;s <i>not<\/i> staying up until 2:00 AM testing scripts that <a href=\"http:\/\/www.microsoft.com\/technet\/scriptcenter\/funzone\/games\/games08\/bevent9.mspx\"><b>calculate the amount of water required to fill a swimming pool<\/b><\/a>.) Instead, the best thing about the Scripting Games is the fact that the Scripting Guys get to do all the Scripting Games-related work <i>plus<\/i> our regular jobs; it&rsquo;s like working two full-time jobs but only getting paid for one! Have you ever wondered how Microsoft managed to sock away so much money? Well, now you know. <\/p>\n<table cellpadding=\"0\" cellspacing=\"0\" class=\"dataTable\" id=\"ENE\">\n<thead><\/thead>\n<tbody>\n<tr valign=\"top\" class=\"record\">\n<td>\n<p class=\"lastInCell\"><b>Ed<\/b><b>itor&rsquo;s Note:<\/b> Okay, we all know how overworked the Scripting Guy who writes this column is. Although, would you like to take a guess as to who had the idea for the Scripting Games in the first place? And who wanted to add even <i>more<\/i> scripting languages? And who wants to start traveling around the world <i>during<\/i> the Scripting Games next year? And who insists we need to get even <i>more<\/i> people to enter the Scripting Games? (Well, okay, that last one would be <i>both<\/i> the nerds &ndash; er, Scripting Guys.) <\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<div class=\"dataTableBottomMargin\"><\/div>\n<p>Speaking of our regular jobs, let&rsquo;s take time out from the Scripting Games to show you a script that can set a reminder on all your Microsoft Outlook appointments and meetings:<\/p>\n<pre class=\"codeSample\">Const olFolderCalendar = 9<\/pre>\n<pre class=\"codeSample\">Set objOutlook = CreateObject(\"Outlook.Application\")<br \/>Set objNamespace = objOutlook.GetNamespace(\"MAPI\")<br \/>Set objFolder = objNamespace.GetDefaultFolder(olFolderCalendar)<\/pre>\n<pre class=\"codeSample\">Set colItems = objFolder.Items<\/pre>\n<pre class=\"codeSample\">For Each objItem in colItems<br \/>&nbsp;&nbsp;&nbsp; objItem.ReminderSet = True<br \/>&nbsp;&nbsp;&nbsp; objItem.ReminderMinutesBeforeStart = 15<br \/>&nbsp;&nbsp;&nbsp; objItem.Save<br \/>Next<\/pre>\n<p>As you can see, this is actually a pretty simple little script. We start out by defining a constant named olFolderCalendar and setting the value to 9; this tells the script which Outlook folder we want to work with. After defining the constant we create an instance of the <b>Outlook.Application<\/b> object, then use the following line of code to bind to the MAPI namespace:<\/p>\n<pre class=\"codeSample\">Set objNamespace = objOutlook.GetNamespace(\"MAPI\")<\/pre>\n<table cellpadding=\"0\" cellspacing=\"0\" class=\"dataTable\" id=\"EOF\">\n<thead><\/thead>\n<tbody>\n<tr valign=\"top\" class=\"record\">\n<td>\n<p><b>Scripting trivia time<\/b>. As it turns out, the MAPI namespace is the <i>only<\/i> namespace you can bind to when using Microsoft Outlook. Nevertheless you still need to call the <b>GetNamespace<\/b> method and explicitly bind to the MAPI namespace. Leave this line of code out and your script will be doomed to fail.<\/p>\n<p>That&rsquo;s right: <i>doomed<\/i>.<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<div class=\"dataTableBottomMargin\"><\/div>\n<p>Once we&rsquo;ve made the connection to the MAPI namespace we can call the <b>GetDefaultFolder<\/b> method to bind to the Outlook calendar (we know we&rsquo;ll be binding to the Calendar because we pass GetDefaultFolder the constant olFolderCalendar):<\/p>\n<pre class=\"codeSample\">Set objFolder = objNamespace.GetDefaultFolder(olFolderCalendar)<\/pre>\n<p>As soon as we&rsquo;re hooked up to the calendar we can retrieve a collection of all our calendar items (meetings and appointments) by using the following line of code:<\/p>\n<pre class=\"codeSample\">Set colItems = objFolder.Items<\/pre>\n<p>Now we&rsquo;re ready for action. In order to set a reminder on all our calendar items we first need to set up a For Each loop that walk us through all the items in the collection; that&rsquo;s what this line of code is for:<\/p>\n<pre class=\"codeSample\">For Each objItem in colItems<\/pre>\n<p>Inside that loop, the first thing we do for each appointment is set the value of the <b>ReminderSet<\/b> property to True; that&rsquo;s going to attach a reminder to each of our appointments. We then set the value of the <b>ReminderMinutesBeforeStart<\/b> property to 15; in other words, we&rsquo;re going to get a reminder 15 minutes before our appointment\/meeting is scheduled to begin. Need more warning (or maybe less warning) than that? That&rsquo;s fine; you can set ReminderMinutesBeforeStart to any value you desire. For example, this line of code causes the reminder to pop 30 minutes before start time:<\/p>\n<pre class=\"codeSample\">objItem.ReminderMinutesBeforeStart = 30<\/pre>\n<p>Believe it or not, we&rsquo;re almost done; all we have to do now is call the <b>Save<\/b> method and we&rsquo;ll have added a reminder to the first item in our collection:<\/p>\n<pre class=\"codeSample\">objItem.Save<\/pre>\n<p>And then it&rsquo;s back to the top of the loop, where we repeat the process with the next item in the collection.<\/p>\n<p>This all works pretty well, but there are a couple things you should be aware of. For one, this script will set a reminder on <i>all<\/i> your appointments and meetings, even those that have already taken place. For example, if you run the script as-is be prepared for a dialog box to pop up and remind you of 76 previous engagements, engagements that are now way overdue. Do we know for <i>sure<\/i> that this will happen? Let&rsquo;s put it this way: you&rsquo;re listening to the voice of experience on this one.<\/p>\n<table cellpadding=\"0\" cellspacing=\"0\" class=\"dataTable\" id=\"EGH\">\n<thead><\/thead>\n<tbody>\n<tr valign=\"top\" class=\"record\">\n<td>\n<p class=\"lastInCell\"><b>Note<\/b>. Is there a way to work around that? Sure; take a <a href=\"http:\/\/www.microsoft.com\/technet\/scriptcenter\/resources\/qanda\/aug07\/hey0828.mspx\"><b>peek at this<\/b><\/a><i>Hey, Scripting Guy!<\/i> column to see how you filter appointments by start date.<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<div class=\"dataTableBottomMargin\"><\/div>\n<p>Second, this script will set a reminder on <i>all<\/i> your appointments (and, of course, each reminder will be set to pop up 15 minutes before start time). It&rsquo;s possible you don&rsquo;t want reminders on all your appointments, or maybe you want different reminder times for different meetings. That&rsquo;s beyond what we can talk about in today&rsquo;s column. However, we <i>do<\/i> have an <a href=\"http:\/\/www.microsoft.com\/technet\/scriptcenter\/resources\/officetips\/aug05\/tips0818.mspx\"><b>Office Space article<\/b><\/a> that discusses filtering in some depth; that&rsquo;s your ticket to selectively picking which appointments to add a reminder to (e.g., all those scheduled by your manager) and which ones to leave alone.<\/p>\n<p>Oh, what the heck; it <i>would<\/i> be easier to just show you some sample code, wouldn&rsquo;t it? The following script filters out any appointments that have a <b>Start<\/b> date earlier than today (that is, the appointments have already occurred); it also filters out any appointments that already have a reminder set. (That way you won&rsquo;t override a 1-hour reminder with your 15-minute reminder.) We thought some of you might find this useful:<\/p>\n<pre class=\"codeSample\">Const olFolderCalendar = 9<\/pre>\n<pre class=\"codeSample\">Set objOutlook = CreateObject(\"Outlook.Application\")<br \/>Set objNamespace = objOutlook.GetNamespace(\"MAPI\")<br \/>Set objFolder = objNamespace.GetDefaultFolder(olFolderCalendar)<\/pre>\n<pre class=\"codeSample\">Set colItems = objFolder.Items<\/pre>\n<pre class=\"codeSample\">strFilter = \"[ReminderSet] = False AND [Start] &gt;= '2\/21\/2008'\"<br \/>Set colFilteredItems = colItems.Restrict(strFilter)<\/pre>\n<pre class=\"codeSample\">For Each objItem In colFilteredItems<br \/>&nbsp;&nbsp;&nbsp; objItem.ReminderSet = True<br \/>&nbsp;&nbsp;&nbsp; objItem.ReminderMinutesBeforeStart = 15<br \/>&nbsp;&nbsp;&nbsp; objItem.Save<br \/>Next<\/pre>\n<p>That should do it, PS. Right now it&rsquo;s time for the Scripting Guy who writes this column to get back to scoring events for the <a href=\"http:\/\/www.microsoft.com\/technet\/scriptcenter\/funzone\/games\/games08\/prizes.mspx\"><b>2008 Winter Scripting Games<\/b><\/a>. Remember, there&rsquo;s still plenty of time to submit scripts for Events 3 and 4; the deadline isn&rsquo;t until tomorrow morning (February 22<sup>nd<\/sup>) at 8:00 AM Pacific Standard Time, which means there&rsquo;s still plenty of time to earn a coveted Scripting Games <a href=\"http:\/\/www.microsoft.com\/technet\/scriptcenter\/funzone\/games\/default.mspx\"><b>Certificate of Excellence<\/b><\/a>.<\/p>\n<p>You say you have one last question? Does the Scripting Guy who writes this column rely on Outlook reminders to tell him when it&rsquo;s time to get back to work? No, he doesn&rsquo;t. Instead he just waits for the Scripting Editor to stand in the doorway, arms crossed, and eyes glaring. That&rsquo;s usually reminder enough that it&rsquo;s time to get back to work. Which, now that we mention it &hellip;.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hey, Scripting Guy! My manager does not like appointment reminders; therefore every meeting request she sends is without reminders.&nbsp; I like reminders and I try to remember to turn them on, but sometimes I forget; that means that if I&#8217;m not on top of my schedule, I can miss a meeting.&nbsp;How can I write a [&hellip;]<\/p>\n","protected":false},"author":595,"featured_media":87096,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[212,49,3,5],"class_list":["post-56153","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-microsoft-outlook","tag-office","tag-scripting-guy","tag-vbscript"],"acf":[],"blog_post_summary":"<p>Hey, Scripting Guy! My manager does not like appointment reminders; therefore every meeting request she sends is without reminders.&nbsp; I like reminders and I try to remember to turn them on, but sometimes I forget; that means that if I&#8217;m not on top of my schedule, I can miss a meeting.&nbsp;How can I write a [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/56153","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/users\/595"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/comments?post=56153"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/56153\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media\/87096"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media?parent=56153"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=56153"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=56153"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}