Sending emails with attachments using reminder

NewAtVba

New Member
Joined
Jun 1, 2011
Messages
16
Hi, i recently bought "Office VBA Macros You Can Use Today". I am trying out the outlook macro that sends out emails with attachments when a reminder occurs.

This is the code.

Option Explicit
'****
Private Sub Application_Reminder(ByVal Item As Object)
Call SendFiles(Item)
End Sub

Private Sub SendFiles(objTask As TaskItem)
Dim objMail As Object
Dim msg As Object
Dim strCategoryName As String
Dim strFileName As String
Dim strContact
Dim i As Integer 'Counter
On Error GoTo ErrorHandler

strCategoryName = "Custom"
If Not objTask.Categories = strCategoryName Then Exit Sub

If Dir(objTask.Body) = "" Then Exit Sub
strFileName = Trim(objTask.Body)
Set objMail = Application.CreateItem(olMailItem)
With objMail
.Subject = objTask.Subject
.Attachments.Add strFileName
strContact = Split(objTask.ContactNames, ",")


If Not IsArray(strContact) Then
strContact = Split(objTask.ContactNames, ",")
End If


For i = 0 To UBound(strContact)
.Recipients.Add strContact(i)
Next i
.Send
End With

With objTask
.ReminderSet = False
.Close olSave
End With

ExitSub:
Exit Sub
ErrorHandler:
MsgBox Err.Number & "-" & Err.Description, _
vbOKOnly + vbExclamation, "Error"
GoTo ExitSub
End Sub


The code compiles with no errors; i've put the filename in the body of the reminder; i've changed and placed the task in the correct category called 'Custom' but when the reminder fires, nothing is sent out at all, with no errors as well.

I believe it's not sending because of the contacts part(in red font) of the code. i've also tried placing contacts in a 'Custom' category as well but that did not work.

The example shown in the book shows outlook 2003. im wondering if that makes a difference?
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".

Forum statistics

Threads
1,224,613
Messages
6,179,904
Members
452,948
Latest member
Dupuhini

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top