Receives a specified email's categories from Office 365 or Exchange Server.
[Visual Basic 6.0]
Public Function GetCategories( _
info As MailInfo
) As CategoryCollection
[Visual C++]
public: HRESULT GetCategories(
IMailInfo* info,
ICategoryCollection* pVal
);
Parameters
Return Value
Remarks
Example
[VB 6.0]
const GetMailInfos_All = 1
const GetMailInfos_NewOnly = 2
const GetMailInfos_ReadOnly = 4
const GetMailInfos_SeqRange = 8
const GetMailInfos_UIDRange = 16
const GetMailInfos_PR_ENTRYID = 32
const GetMailInfos_DateRange = 64
const GetMailInfos_OrderByDateTime = 128
const GetMailInfos_GetCategories = 256
const GetMailInfos_ImapDeleted = 512
const GetMailInfos_ImapUndeleted = 1024
const GetMailInfos_GetFollowUpFlag = 2048
const GetMailInfos_IncludeAllFolders = 4096
' you must use EWS or Graph API to connect the server
client.Connect server
' retrieve categories and follow up flag to MailInfo
client.GetMailInfosParam.Reset
Dim options
options = options Or GetMailInfos_GetCategories
options = options Or GetMailInfos_GetFollowUpFlag
client.GetMailInfosParam.GetMailInfosOptions = options
Dim mailInfos
Set mailInfos = client.GetMailInfoList()
Debug.Print "Total " & mailInfos.Length & " email(s)"
Dim i
For i = 0 To mailInfos.Length - 1
Dim mailInfo
Set mailInfo = mailInfos.Item(i)
' if you have set GetMailInfos_GetCategories flag, you don't need to call this method.
client.GetCategories mailInfo
Debug.Print "Index: " & i & ", UIDL: " & mailInfo.UIDL
Debug.Print "Category: " & CategoryToString(mailInfo.Categories)
Next
Function CreateCategories(categoryStr)
Dim categories As New EAGetMailObjLib.CategoryCollection
Dim strs
strs = Split(categoryStr, ";")
Dim i
For i = LBound(strs) To UBound(strs)
Dim category
Set category = CreateObject("EAGetMailObj.Category")
category.Name = Trim(strs(i))
If category.Name <> "" Then
categories.Add category
End If
Next
Set CreateCategories = categories
End Function
Function CategoryToString(categories)
Dim i, str
For i = 0 To categories.Length - 1
Dim category
Set category = categories.Item(i)
str = str & category.Name & "; "
Next
CategoryToString = str
End Function
See Also