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
Ian
___________________________________________________________________________ __________
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
.Display
'.Recipients = olkSND.Recipients
.Recipients = olkSND.Recipients
'.Save
'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
'.Save
.Display
End With
Set objTask = Nothing
Set objMail = Nothing
Set olkSND = Nothing
Set olkSes = Nothing
Set olkApp = Nothing
End With
End Sub
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
Ian
___________________________________________________________________________ __________
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
.Display
'.Recipients = olkSND.Recipients
.Recipients = olkSND.Recipients
'.Save
'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
'.Save
.Display
End With
Set objTask = Nothing
Set objMail = Nothing
Set olkSND = Nothing
Set olkSes = Nothing
Set olkApp = Nothing
End With
End Sub