Microsoft Office Tutorials and References
In Depth Information
Sending Daily Attachments to Certain Recipients
' * * * * *¶
Private Sub SendFiles(objTask As TaskItem)¶
'Outlook objects declaration¶
Dim objMail As Outlook.MailItem¶
Dim strCategoryName As String¶
Dim strFileName As String¶
Dim strContact¶
Dim i As Integer 'Counter¶
On Error GoTo ErrHandler¶
'Custom category that was created to use for this¶
'action¶
strCategoryName = "Daily Report Sender"¶
'If category name doesn't match then quit process¶
'And let reminder run normally¶
If Not objTask.Categories = strCategoryName Then Exit Sub¶
'Verify if specified file exists¶
'Quit process if it does not exist¶
If Dir(objTask.Body) = "" Then Exit Sub¶
'File name that is specified in task body section¶
strFileName = Trim(objTask.Body)¶
'Create mail object¶
Set objMail = Outlook.CreateItem(olMailItem)¶
With objMail¶
'Use same subject with Task Item¶
.Subject = objTask.Subject¶
'Attach related file¶
.Attachments.Add strFileName¶
'Add recipients¶
'Contact Names stores contact names with commas between¶
'DepartmentA, DepartmentB, DepartmentC¶
'So the names are split by using comma as delimiter¶
strContact = Split(objTask.ContactNames, ",")¶
'Checking if language settigns require using¶
' “;” as list separator¶
If Not IsArray(strContact) Then _¶
strContact = Split(objTask.ContactNames, “;”)¶
End if ¶
'Adding recipients to new email message¶
For i = 0 To UBound(strContact)¶
.Recipients.Add strContact(i)¶
Next i¶
'Send message immediately¶
.Send¶
End With¶
With objTask¶
'Close reminder popup¶
.ReminderSet = False¶
.Close olSave¶
End With¶
ExitSub:¶
Exit Sub¶
Out
Search JabSto ::




Custom Search