If you would like to assign an Outlook task to all the email addresses in an Excel file, you can refer to this article. Here we will expose a smart way, which can help you accomplish it just via a click.
Assuming that you have an Excel file which contains the team members who are responsible for a project, and at present you hope to assign an Outlook task to all of them, you can use the piece of VBA code shown in the followings.
Assign a Task to All Email Addresses in an Excel File
- Here we will take the following Excel file as an example.
- At the very outset, you should start your Outlook program.
- Then, in the main Outlook window, switch to “Developer” tab and click on the “Visual Basic” button.
- Next, a new window will display, in which you should enable “Microsoft Excel Object Library”. You can tap on the “Tools” button and choose “Reference”. In the newly popup dialog box, find the object library, check it and hit “OK”.
- Subsequently, copy and paste the following VBA code into an unused module.
Sub AssignTasktoAllEmailAddressesInExcel() Dim strExcelFile As String Dim objExcelApp As Excel.Application Dim objExcelWorkBook As Excel.Workbook Dim objExcelWorkSheet As Excel.Worksheet Dim nRow As Integer Dim nColumn As Integer Dim objTask As Outlook.TaskItem 'Change the path to the source Excel file strExcelFile = "E:\Team Members.xlsx" On Error Resume Next Set objExcelApp = CreateObject("Excel.Application") Set objExcelWorkBook = objExcelApp.Workbooks.Open(strExcelFile) Set objExcelWorkSheet = objExcelWorkBook.Sheets("Sheet1") 'Create a new Task Set objTask = Outlook.Application.CreateItem(olTaskItem) With objTask .Subject = "Test Task 2" .StartDate = #9/11/2017# .DueDate = #9/18/2017# .Body = "This is a test task" End With '!!!Change the row and column as per your own Excel file nRow = 2 nColumn = 4 'Add the email addresses as the Task recipients While objExcelWorkSheet.Cells(nRow, 4) <> "" objTask.Recipients.Add (objExcelWorkSheet.Cells(nRow, 4)) nRow = nRow + 1 Wend 'Send this Task With objTask .Recipients.ResolveAll .Assign .Send End With objExcelWorkBook.Close False objExcelApp.Quit End Sub
- After that, you can try this macro. Just trigger it by clicking the “Run” icon in the toolbar or taping on the “F5” key button.
- At once, the macro will start. Lastly, after it finishes, you will see that a Task is sent out, located in your “Sent Items” folder, like the screenshot below:
Never Fear Outlook Corruption
Due to Outlook’s vulnerability, many users always keep panic when coping with the stack of emails in Outlook. However, actually, as long as you make sufficient precautions, you will not need to fear Outlook damage. For example, you ought to back up your PST data file on a regular basis. Also, you have to learn how to find and run the internal repair tool – Scanpst.exe. Besides, it is also advisable to hold a credible external PST fix utility, such as DataNumen Outlook Repair.
Shirley Zhang is a data recovery expert in DataNumen, Inc., which is the world leader in data recovery technologies, including mdf repair and outlook repair software products. For more information visit www.datanumen.com