Set Email Flag Status in Outlook 2007 - vba

Is there a way in Outlook 2007 to set a follow-up flag on an email object? It looks like it was supported in Outlook 2003 with .FlagStatus property, but I can't find it in 2007.

From the outlook change notes:
For Follow Up Flags For Follow Up Flags, introduced in Microsoft Office Outlook 2003, are replaced by task flags and color categories. You no longer see colored flags in the Mail view. If you flagged items in the earlier version of Outlook to indicate that they were important or that they belonged to a particular group, you should now use color categories instead. If you used flags to indicate the time at which you were to take action on an item, you should now use task flags. This change is being made to increase the functionality of flags. With task flagging, you can place an item in the overall task management system, allowing you to see your tasks in the To-Do Bar, Daily Task List in Calendar, and in the Tasks view. By categorizing an item, you can easily scan your Inbox for categorized items, the same way that you might previously have scanned your Inbox for flagged items. You can also find categorized items in the Categorized Mail Search Folders.
So the concept of the flag changed, which is why the FlagStatus property has changed. According to this, the following should work:
Set SelectedItems = Outlook.ActiveExplorer.Selection
For Each Item In SelectedItems
With Item
.ToDoTaskOrdinal = dtTaskDate
.TaskDueDate = dtTaskDate
.TaskStartDate = dtTaskDate
.FlagStatus = 2
.FlagRequest = strFlagRequest
.Categories = strCategories
.FlagIcon = 6
.Save
End With
Next Item

This is what http://msdn.microsoft.com/en-us/library/microsoft.office.interop.outlook._mailitem.flagstatus.aspx has to say:
Dim instance As _MailItem
Dim value As OlFlagStatus
value = instance.FlagStatus
instance.FlagStatus = value

Related

How to display in Outlook, using VBA, a list of emails based on their EntryID (based on a list of EntryIDs stored in MS Access)

I have an Access DB that interacts with Outlook, including capturing the EntryID of selected emails as needed (which are stored in a table in Access)
I have code that allows users to view any email whose EntryID is stored, using Outlook's GetItemFromID method. This works as needed - it opens up a single email based on its EntryID.
However, what I am now looking to do is to filter the main Outlook window, to show emails based on a list of EntryIDs I have saved. So, for clarification, if I have a list of eg 3 emails (with their respective EntryIDs), the main Outlook window would be filtered to show those 3 emails. So basically like a search, but based on EntryIDs.
I can't seem to find anyway to do this? Perhaps there is a way to add a search filter via VBA that will search based on EntryIDs, but I can't find anything on this.
Any ideas much appreciated.
Binary properties like EntryID can't be used in any search or filtering operation in Outlook. You need to use any other properties (custom or user-defined ones) for filtering items in Outlook.
The View.Filter property value is a string, in DAV Searching and Locating (DASL) syntax, that represents the current filter for the view. For more information about using DASL syntax to filter items in a view, see Filtering Items.
Private Sub FilterViewToLastWeek()
Dim objView As View
' Obtain a View object reference to the current view.
Set objView = Application.ActiveExplorer.CurrentView
' Set a DASL filter string, using a DASL macro, to show
' only those items that were received last week.
objView.Filter = "%lastweek(""urn:schemas:httpmail:datereceived"")%"
' Save and apply the view.
objView.Save
objView.Apply
End Sub
Be aware, the EntryID value can be changed when items are moved between stores or folders. Moreover, the value is unique only per store.
If you need to show some items with specific EntryIDs strings you can get these item instances by using the GetItemFromID method and then marking them with a specific user property to be able to apply a filter for it. Or just add another string field to the Db with a custom value which can be added to items in Outlook, so you could easily apply a filter in the UI.

Identify Outlook meetings that include both a Teams meeting link and a Zoom meeting link

A recent Outlook updates automated the addition of Team links to every meeting invite.
I've had several meetings go sideways because the person distributing the meeting invite wasn't aware.
Is there a configuration or script to scan meetings on my calendar and identify any that have multiple meeting links (e.g., Zoom + Outlook)?
If I have a list I can either fix myself (if I'm the meeting owner) or follow up with the organizer.
Taking a quick look at an appointment set to use both Teams and Zoom, I see in OutlookSpy (I am its author) that there are a few Teams and Zoom specific named properties set (see the screenshot below).
You can search for items with both sets of properties present. The following script should find appointments like that. Assuming you run it from Outlook VBA:
set folder = Application.Session.GetDefaultFolder(olFolderCalendar)
set items = folder.Items.Restrict("#SQL=(""http://schemas.microsoft.com/mapi/string/{00020329-0000-0000-C000-000000000046}/cecp-propertyNames/0x0000001F"" IS NOT NULL) AND " & _
" (""http://schemas.microsoft.com/mapi/string/{00020329-0000-0000-C000-000000000046}/SkypeTeamsMeetingUrl/0x0000001F"" IS NOT NULL) ")
Debug.Print(items.Count)
for each item in items
Debug.Print item.Subject
next
You can create a VBA macro where you could iterate over all appointments/meetings on the calendar and check the RTFBody property whether it contains one or another meeting URL. Also you may optimize the code a bit by getting only specific calendar items or process them in chunks. To get only items that corresponds to your conditions you may use the Find/FindNext or Restrict methods of the Items class. Read more about them in the following articles:
How To: Use Restrict method in Outlook to get calendar items
How To: Retrieve Outlook calendar items using Find and FindNext methods

VBA Replacement for Flag Status

According to documentation, the MailItem.FlagStatus property in Outlook is deprecated. So what does Outlook use to mark a mail item as "in progress" or "waiting on someone else" when said item is flagged and thus appears in the to-do list? I'd like to programatically change the status of items in the to do list, but only Task Items have the Status property and I can't figure out the correct equivalent for mail items.
While Programmatically setting a MailItem's followup flag to complete? is related, I don't believe it answers my question. The Flag Request property appears to document the associated follow up action, rather than assigning one of the standard statuses used for Task Items (Not Started, In Progress, Waiting on Someone Else, Deferred, Completed).
What I'm trying to do is this: outlook's to-do view allows you to set the Status of both task items and flagged mail items.
You can also set the status of task items programmatically by assigning to the Status property, e.g. myTaskItem.Status = olTaskWaiting sets the status to "Waiting on Someone Else". I'm trying to figure out how to do the same thing to mail items. I have attempted to do this via myMailItem.FlagStatusand been unsuccessful: while Flag Status does correspond to some of the statuses, it does not do so uniquely (0 seems to equal both In Progress and Deferred). Since Flag Status is deprecated anyway, I thought there might be some other way to set these values.
My Progress:
This page has someone with nearly exactly the same question I do, and the answer seems to suggest that the "status" property is added directly to the mail item when it is flagged as a to-do. However, I'm not sure under what name task status has been added. Item.Status gives me the error "Object doesn't support this property or method", and Item.UserProperties("Status") also gives an error.
My take on this is that because FlagIcon and FlagStatus are deprecated (and probably have been since OL2007), everyone needs to rethink their objectives and revise their VBA code. At some point, Outlook will stop putting values in those properties (or the properties will go away and throw an error).
My code was looking for instances in which a mail item had a follow-up flag but no reminder. My rule was that mail requiring follow-up should have a reminder. In the new system, it looks like mail follow-up is similar to task follow-up, so looking at the mail item as a task, my code now looks for mail items that have a start or due date and are not completed but have no reminder set, as in the following:
If (myMail.TaskStartDate <> #1/1/4501# _
Or _
myMail.TaskDueDate <> #1/1/4501#) _
And myMail.TaskCompletedDate = #1/1/4501# _
And Not myMail.ReminderSet Then
'Do something here ...
End If
This is a lot more complex than before, but what can you do in the face of progress? :-D
(P.S. If there is a better way to code for "no date" than "#1/1/4501#" please let me know.)

outlook vba code to display pictures in email

By default, my MS Outlook 2013 is set NOT to download images in received HTML e-mail messages. I would like to keep this setting.
There are some senders whose emails are handled by my Outlook VBA code...and filed into specific folders (rather than the INBOX). I do not use the in-built RULES.
These are known senders...and I would like to have the pictures in the emails from these SELECT KNOWN senders downloaded and displayed. I could do this manually for each email... by right clicking etc... but that is a pain... when there are many such emails.
I am unable to figure out the few lines of code (one line ?) required to download / enable display of images / pictures in the email. Something like... MailItem.Display (which does not work... it only displays the mail in an independent window)... or MailItem.DisplayImages (that is not a known method!).
I would include this one line (or lines) in the routine which handles emails from some known senders....so that their emails always have images / pictures downloaded and displayed.
Thanks.
You would need to set the PidTagBlockStatus property - see http://msdn.microsoft.com/en-us/library/ee219242(v=exchg.80).aspx.
Note that while you can read/write that property using MailItem.PropertyAccessor.SetProperty, you will not be able to calculate its value correctly - Outlook Object Model rounds off the value of the message delivery time, and you would need the raw Extended MAPI value (accessible in C++ or Delphi only) as the FileTime structure.
If using Redemption (I am its author) is an option, it exposes the RDOMail.DownloadPictures property. Something like the following should do the job (VB script):
set Session = CreateObject("Redemption.RDOSession")
Session.MAPIOBJECT = Application.Session.MAPIOBJECT
set Item = Session.GetRDOObjectFromOutlookObject(YourOutlookItem)
Item.DownloadPictures = true
Item.Save
The Outlook object model doesn't provide any property or method for that.

Programatically Show/Hide the FROM field in Outlook using c#

Is there any way to show/hide the FROM field in Outlook programatically?
The reason I want to do this, is because some code i've wrote so far successfully sets the FROM field.
However, after the first time it is ran, the FROM field is set, but the UI doesn't reflect this change.
Hiding and then re-showing the FROM field forces the UI to update. Ideally I want to find a way to do this in both 2007 and 2010.
If it isn't possible to hide and re-show the FROM field programatically is there any other way to force the UI to refresh?
//Get the explorer window and the currently selected item
Explorer activeExplorer = this.Application.ActiveExplorer();
MailItem origMsg = activeExplorer.Selection[1];
Recipients origRecipients = origMsg.Recipients;
if (origRecipients.Count == 1)
{
AddressEntry address = origRecipients[1].AddressEntry;
currentMsg.Sender = address;
//currentMsg.SentOnBehalfOfName = origRecipients[1].Name; currentMsg.send
}