VBA with Outlook

Ron99

Active Member
Joined
Feb 10, 2010
Messages
347
Office Version
  1. 2016
Platform
  1. Windows
I would like to link excel with outlook, this is for 2007, I already have a code, but the alert is hitting the person's inbox rather than his task in outlook, I just need this code to be changed from going into the inbox it should go under task, here is the code


Sub TestFile()
Dim OutApp As Object
Dim OutMail As Object
Dim cell As Range
Application.ScreenUpdating = False
Set OutApp = CreateObject("Outlook.Application")
On Error GoTo cleanup
For Each cell In Columns("B").Cells.SpecialCells(xlCellTypeConstants)
If cell.Value Like "?*@?*.?*" And _
LCase(Cells(cell.Row, "C").Value) = "yes" Then
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.To = cell.Value
.Subject = "Activity Reminder"
.Body = "Dear " & Cells(cell.Row, "A").Value _
& vbNewLine & vbNewLine & _
"Please complete your pending task " & Cells(cell.Row, "D") & " By " & Cells(cell.Row, "E")
'You can add files also like this
'.Attachments.Add ("C:\test.txt")
.Send 'Or use Display
End With
On Error GoTo 0
Set OutMail = Nothing
End If
Next cell
cleanup:
Set OutApp = Nothing
Application.ScreenUpdating = True
End Sub <!-- / message -->
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Hi,

As per the link, I tried using the code, but it doesnt work, come up with an error in this line

Dim olTsk As TaskItem


The code from the link have pasted below

Sub TestTask()
' Note: You must first manually bind the Outlook
' 10.0 Object Library by going to Tool,
' References in the VBA editor (this is for
' Outlook 2002). Otherwise the code
' below will not work!

Dim olApp As Object
Dim olTsk As TaskItem

Dim Recipient As String
Recipient = "Mark Walker"

Set olApp = CreateObject("Outlook.Application")
Set olTsk = olApp.CreateItem(olTaskItem)

With olTsk
.Status = olTaskInProgress
.Importance = olImportanceHigh
.DueDate = DateValue("06/26/05")
.Body = "Test task body"
.TotalWork = 40
.ActualWork = 20
.Assign = "Test Task Mark Walker"
.Owner = "Mark Walker"
.Save
.Send
End With

Set olTsk = Nothing
Set olApp = Nothing

End Sub
 
Upvote 0
Dis you do this part?
' Note: You must first manually bind the Outlook
' 10.0 Object Library by going to Tool,
' References in the VBA editor (this is for
' Outlook 2002). Otherwise the code
' below will not work!
 
Upvote 0

Forum statistics

Threads
1,224,604
Messages
6,179,857
Members
452,948
Latest member
UsmanAli786

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