
Forward to Toodledo Outlook Macros
By:
Joel-Tang on
Jul 30th, 2012 | syntax:
VB.NET | size: 1.71 KB | hits: 89 | expires: Never
Sub NextAction()
Dim objMail As Outlook.MailItem
Set objItem = GetCurrentItem()
Set objMail = objItem.Forward
objMail.To = "yourtoodledoemail@toodledo.com"
' see https://www.toodledo.com/info/help_email.php for proper syntax for the following'
objMail.Subject = objMail.Subject & " ! @context $status +goals *project"
objMail.Display
objMail.Categories = "Next Action"
objMail.Send
Set objItem = Nothing
Set objMail = Nothing
Call MoveToFolder
End Sub
Function GetCurrentItem() As Object
Dim objApp As Outlook.Application
Set objApp = Application
On Error Resume Next
Select Case TypeName(objApp.ActiveWindow)
Case "Explorer"
Set GetCurrentItem = _
objApp.ActiveExplorer.Selection.Item(1)
Case "Inspector"
Set GetCurrentItem = _
objApp.ActiveInspector.CurrentItem
Case Else
End Select
End Function
'Outlook VB Macro to move selected mail item(s) to a target folder
Sub MoveToFolder()
On Error Resume Next
Dim ns As Outlook.NameSpace
Dim moveToFolder As Outlook.MAPIFolder
Dim objItem As Outlook.MailItem
Set ns = Application.GetNamespace("MAPI")
'Define path to the target folder
Set moveToFolder = ns.Folders("yourEmail@Email.com").Folders("Active").Folders("Project")
If Application.ActiveExplorer.Selection.Count = 0 Then
MsgBox ("No item selected")
Exit Sub
End If
If moveToFolder Is Nothing Then
MsgBox "Target folder not found!", vbOKOnly + vbExclamation, "Move Macro Error"
End If
For Each objItem In Application.ActiveExplorer.Selection
If moveToFolder.DefaultItemType = olMailItem Then
If objItem.Class = olMail Then
objItem.Move moveToFolder
End If
End If
Next
Set objItem = Nothing
Set moveToFolder = Nothing
Set ns = Nothing
End Sub