Collecting mail address from GAB and adding to Outlook Task

Not open for further replies.


New Member
Outlook version
Outlook 2013 32 bit
Email Account
Exchange Server
Hi All,

I am trying to create an automated Outlook (2013) task that requests an email address selection from Global Address List and then adds the selected address to the TO field under Assign Tasks.

See the current VBA code that works but does not add the email address to the To Field, Please can someone help me..

Many Thanks

___________________________________________________________________________ __________

Sub ConvertSelectedMailtoTask()
Dim objTask As Outlook.TaskItem
Dim objMail As Outlook.MailItem
Dim myDelegate As Outlook.Recipient
Dim olkApp As Outlook.Application, olkSes As Outlook.NameSpace, olkSND As Outlook.SelectNamesDialog

Set objTask = Application.CreateItem(olTaskItem)
Set objMail = Application.ActiveExplorer.Selection.Item(1)
'Set Myaddrlist = myNameSpace.AddressLists("Global Address List")
Set olkApp = GetObject(, "Outlook.Application")
Set olkSes = olkApp.Session
Set olkSND = olkSes.GetSelectNamesDialog
'Set myDelegate = MyItem.Recipients.Add()

CompanyName = InputBox("Please enter Company name, That this task is being created for.")

With olkSND
.AllowMultipleSelection = False
'.Recipients = olkSND.Recipients

.Recipients = olkSND.Recipients

'The selections the user makes will be in the olkSND.Recipients collection'

With objTask

.Subject = objMail.Subject & CompanyName
.StartDate = objMail.ReceivedTime
.DueDate = Date + 30.5 '3 days at noon
.ReminderSet = True
.ReminderTime = objTask.DueDate - 10.5
.Categories = "Customer Updates Required"
'.Recipients = olkSND.Recipients
.Importance = olImportanceHigh
.Body = objMail.Body
'Add the message as an attachment
.Attachments.Add objMail

End With

Set objTask = Nothing
Set objMail = Nothing
Set olkSND = Nothing
Set olkSes = Nothing
Set olkApp = Nothing

End With

End Sub

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
ok... you also forgot to assign it -
.Recipients.Add (sendTo)

sendTo comes from the address book:

With olkSND
.AllowMultipleSelection = False
sendTo = .Recipients(1).AddressEntry

you could use olkSND.Recipients(1).AddressEntry in recipient.add instead of sendto (but it's better to use variables)
Not open for further replies.
Thread starter Similar threads Forum Replies Date
V Collecting email from my domains and aggregating them in Hotmail Using accounts in Outlook 7
ThinkToday Calculate reply time of outlook mail Using Outlook 1
B Outlook 2010 Opening Mail Attachment Using Outlook 2
e_a_g_l_e_p_i Is it possible it set the fonts used to read incoming mail Using Outlook 11
D Mail in Sent Items Gone Using Outlook 13
M Managing Gmail "All Mail" sync issues with IMAP Using Outlook 1
GregS Outlook 2016 Sent Mail absent from Sent Mail or Sent Items Folders Using Outlook 8
GregS Why is Outlook 2016 mail in Using Outlook 1
S Outlook not receiving mail Using Outlook 2
Commodore Outlook (2013) issues with mail Using Outlook 0
GregS Outlook 2016 iPhone won't download Outlook 2016 Mail. Using Outlook 0
A Arthur needs help with 2007 Outlook e-mail Using accounts in Outlook 3
oliv- How to distinguish whether mail is incoming or outgoing? Outlook VBA and Custom Forms 2
W Receiving mail for account that has been deleted Using Outlook 2
H In outlook 365 POP mail Inbox, email takes a long time or never arrives. Using Outlook 1
Z Add text to auto-forwarded e-mail Outlook VBA and Custom Forms 4
O How to prevent CC from showing when creating a new mail? Using Outlook 1
I Junk Mail and PersonMetadata Using Outlook 2
T 3 months of archived e-mail is missing Using Outlook 1
B Outlook - Mail from safe senders list being sent to Spam Folder Using Outlook 0
G Detect Google Drive and OneDrive links in incoming mail Outlook VBA and Custom Forms 3
M Sent mail not showing in Sent Items folder; but they can be found with Search Using Outlook 3
H Outlook 2016 sent over 30 copies of an e-mail with attachments Using Outlook 1
T Missing text in e-mail message after "(Please keep confidential)" Using Outlook 3
Victor_50 Outlook 2013 Custom Contact Form starts with "E-mail 2" Outlook VBA and Custom Forms 2
E Mail sorting view issue Using Outlook 1
D after delete mail, open the next one Outlook VBA and Custom Forms 0
RBLampert Assigning a newly (re)created e-mail account to a specific .pst data file Using Outlook 2
B Clear Offline Items (Mail Folder) via VBA Outlook VBA and Custom Forms 1
M Moving mail to another folder is much slower than before (Office365) Using Outlook 0
A Outlook macro to create search folder with mail categories as criteria Outlook VBA and Custom Forms 3
N VBA Script to Open highlighted e-mail and Edit Message Outlook VBA and Custom Forms 5
M Auto-export mail to Excel Outlook VBA and Custom Forms 2
M Sent mail not showing in my sent folder Using Outlook 9
B iCloud Option to sync contacts, mail, calendar and tasks Using Outlook 5
O Using .OST and .PST mail thru different providers Using Outlook 5
CWM030 Connected accounts mail moved to trash? Exchange Server Administration 16
N Tracking Mail items being moved to folders Outlook VBA and Custom Forms 5
Mark Foley Color Categories on IMAP mail lost when installing new Windows 7 workstation Using Outlook 12
E Copying the whole e-mail body into excel Outlook VBA and Custom Forms 0
D Print attachments automatically and moves the mail to a new folder Outlook VBA and Custom Forms 9
P when i move inbox mails to another folder in outlook the mail disappears Using Outlook 1
E Copy e-mail body from outlook and insert into excel Outlook VBA and Custom Forms 3
soadfan Outlook won't send e-mail when offline Outlook VBA and Custom Forms 19
E Copying data from e-mail attachement to EXCEL file via macro Outlook VBA and Custom Forms 38
Peter H Williams How to Move Mail item after processing Outlook VBA and Custom Forms 5
I How to receive mails on behalf of when sent to group mail? Using Outlook 2
K Delay Send and Mail Merge Outlook VBA and Custom Forms 4
Similar threads