![]() |
Automate Email
I'm running Outlook 2003 on Exchange 2003 server.
I would like to schedule an automated email that will be send out to the same recipients with the same msg everyday from Mon-Fri in the morning. All I have so far is the following code. How do I tell Outlook to do this automatically every morning? Attribute VB_Name = "Module1" Option Explicit Sub SendMail() Dim olApp As Outlook.Application Dim olMail As Outlook.MailItem Dim blRunning As Boolean 'get application blRunning = True On Error Resume Next Set olApp = GetObject(, "Outlook.Application") If olApp Is Nothing Then Set olApp = New Outlook.Application blRunning = False End If On Error GoTo 0 Set olMail = olApp.CreateItem(olMailItem) With olMail 'Specify the email subject ..Subject = "Pick up the Mail" 'Specify who it should be sent to 'Repeat this line to add further recipients ..Recipients.Add ..Body = "This is today's pick up mail reminder." 'Choose which of the following 2 lines to have commented out ..Display 'This will display the message for you to check and send yourself '.Send ' This will send the message straight away End With If Not blRunning Then olApp.Quit Set olApp = Nothing Set olMail = Nothing End Sub Paul |
Automate Email
wFor starters, you couldn't automate this from an external .exe or script
that starts Oultook and creates an e-mail message, as that's not supported. The Outlook Object Model is unsuitable to run in a Windows service: http://support.microsoft.com/default...b;en-us;237913 A server-side solution is best, but that involves creating an Exchange Event Sink and is very advanced. The best option is to create a recurring task and write VBA to trap the Reminder event to check that it is your defined task, then run your code to create and send an e-mail. -- Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration) Try Picture Attachments Wizard for Outlook: http://www.collaborativeinnovations.ca Blog: http://blogs.officezealot.com/legault/ "A+P" wrote: I'm running Outlook 2003 on Exchange 2003 server. I would like to schedule an automated email that will be send out to the same recipients with the same msg everyday from Mon-Fri in the morning. All I have so far is the following code. How do I tell Outlook to do this automatically every morning? Attribute VB_Name = "Module1" Option Explicit Sub SendMail() Dim olApp As Outlook.Application Dim olMail As Outlook.MailItem Dim blRunning As Boolean 'get application blRunning = True On Error Resume Next Set olApp = GetObject(, "Outlook.Application") If olApp Is Nothing Then Set olApp = New Outlook.Application blRunning = False End If On Error GoTo 0 Set olMail = olApp.CreateItem(olMailItem) With olMail 'Specify the email subject ..Subject = "Pick up the Mail" 'Specify who it should be sent to 'Repeat this line to add further recipients ..Recipients.Add ..Body = "This is today's pick up mail reminder." 'Choose which of the following 2 lines to have commented out ..Display 'This will display the message for you to check and send yourself '.Send ' This will send the message straight away End With If Not blRunning Then olApp.Quit Set olApp = Nothing Set olMail = Nothing End Sub Paul |
Automate Email
Hi Eric,
Thanks for your reply. I do have a generic code that will send an email on all task reminder event notifications. But how do I change it so it traps an event with the subject line: "Pick Up Mail" ? Private Sub Application_Reminder(ByVal Item As Object) Dim objMsg As MailItem ' create new outgoing message Set objMsg = Application.CreateItem(olMailItem) ' your reminder notification address objMsg.To = " objMsg.CC = " objMsg.Subject = "Reminder: " & Item.Subject ' handle task items that generate reminders Select Case Item.Class Case olTask '48 objMsg.Body = _ "Start: " & Item.StartDate & vbCrLf & _ "End: " & Item.DueDate & vbCrLf & _ "Details: " & vbCrLf & Item.Body End Select ' send the message objMsg.Send Set objMsg = Nothing End Sub Paul "Eric Legault [MVP - Outlook]" wrote in message ... wFor starters, you couldn't automate this from an external .exe or script that starts Oultook and creates an e-mail message, as that's not supported. The Outlook Object Model is unsuitable to run in a Windows service: http://support.microsoft.com/default...b;en-us;237913 A server-side solution is best, but that involves creating an Exchange Event Sink and is very advanced. The best option is to create a recurring task and write VBA to trap the Reminder event to check that it is your defined task, then run your code to create and send an e-mail. -- Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration) Try Picture Attachments Wizard for Outlook: http://www.collaborativeinnovations.ca Blog: http://blogs.officezealot.com/legault/ "A+P" wrote: I'm running Outlook 2003 on Exchange 2003 server. I would like to schedule an automated email that will be send out to the same recipients with the same msg everyday from Mon-Fri in the morning. All I have so far is the following code. How do I tell Outlook to do this automatically every morning? Attribute VB_Name = "Module1" Option Explicit Sub SendMail() Dim olApp As Outlook.Application Dim olMail As Outlook.MailItem Dim blRunning As Boolean 'get application blRunning = True On Error Resume Next Set olApp = GetObject(, "Outlook.Application") If olApp Is Nothing Then Set olApp = New Outlook.Application blRunning = False End If On Error GoTo 0 Set olMail = olApp.CreateItem(olMailItem) With olMail 'Specify the email subject ..Subject = "Pick up the Mail" 'Specify who it should be sent to 'Repeat this line to add further recipients ..Recipients.Add ..Body = "This is today's pick up mail reminder." 'Choose which of the following 2 lines to have commented out ..Display 'This will display the message for you to check and send yourself '.Send ' This will send the message straight away End With If Not blRunning Then olApp.Quit Set olApp = Nothing Set olMail = Nothing End Sub Paul |
Automate Email
Simple! The Item object passed an argument to the Reminder event can be
casted to a TaskItem object where you have full access to all its properties (e.g. TaskItem.Subject, etc.). If it equals what you expect, run your e-mail code otherwise exit. -- Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration) Try Picture Attachments Wizard for Outlook: http://www.collaborativeinnovations.ca Blog: http://blogs.officezealot.com/legault/ "A+P" wrote: Hi Eric, Thanks for your reply. I do have a generic code that will send an email on all task reminder event notifications. But how do I change it so it traps an event with the subject line: "Pick Up Mail" ? Private Sub Application_Reminder(ByVal Item As Object) Dim objMsg As MailItem ' create new outgoing message Set objMsg = Application.CreateItem(olMailItem) ' your reminder notification address objMsg.To = " objMsg.CC = " objMsg.Subject = "Reminder: " & Item.Subject ' handle task items that generate reminders Select Case Item.Class Case olTask '48 objMsg.Body = _ "Start: " & Item.StartDate & vbCrLf & _ "End: " & Item.DueDate & vbCrLf & _ "Details: " & vbCrLf & Item.Body End Select ' send the message objMsg.Send Set objMsg = Nothing End Sub Paul "Eric Legault [MVP - Outlook]" wrote in message ... wFor starters, you couldn't automate this from an external .exe or script that starts Oultook and creates an e-mail message, as that's not supported. The Outlook Object Model is unsuitable to run in a Windows service: http://support.microsoft.com/default...b;en-us;237913 A server-side solution is best, but that involves creating an Exchange Event Sink and is very advanced. The best option is to create a recurring task and write VBA to trap the Reminder event to check that it is your defined task, then run your code to create and send an e-mail. -- Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration) Try Picture Attachments Wizard for Outlook: http://www.collaborativeinnovations.ca Blog: http://blogs.officezealot.com/legault/ "A+P" wrote: I'm running Outlook 2003 on Exchange 2003 server. I would like to schedule an automated email that will be send out to the same recipients with the same msg everyday from Mon-Fri in the morning. All I have so far is the following code. How do I tell Outlook to do this automatically every morning? Attribute VB_Name = "Module1" Option Explicit Sub SendMail() Dim olApp As Outlook.Application Dim olMail As Outlook.MailItem Dim blRunning As Boolean 'get application blRunning = True On Error Resume Next Set olApp = GetObject(, "Outlook.Application") If olApp Is Nothing Then Set olApp = New Outlook.Application blRunning = False End If On Error GoTo 0 Set olMail = olApp.CreateItem(olMailItem) With olMail 'Specify the email subject ..Subject = "Pick up the Mail" 'Specify who it should be sent to 'Repeat this line to add further recipients ..Recipients.Add ..Body = "This is today's pick up mail reminder." 'Choose which of the following 2 lines to have commented out ..Display 'This will display the message for you to check and send yourself '.Send ' This will send the message straight away End With If Not blRunning Then olApp.Quit Set olApp = Nothing Set olMail = Nothing End Sub Paul |
Automate Email
Hi Eric,
Ok, how's this? Dim TaskItem As Item.Class If TaskItem.Subject = "Pick Up Mail" Then ...... compose email and send... ...... End If Paul "Eric Legault [MVP - Outlook]" wrote in message ... Simple! The Item object passed an argument to the Reminder event can be casted to a TaskItem object where you have full access to all its properties (e.g. TaskItem.Subject, etc.). If it equals what you expect, run your code otherwise exit. -- Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration) Try Picture Attachments Wizard for Outlook: http://www.collaborativeinnovations.ca Blog: http://blogs.officezealot.com/legault/ "A+P" wrote: Hi Eric, Thanks for your reply. I do have a generic code that will send an email on all task reminder event notifications. But how do I change it so it traps an event with the subject line: "Pick Up Mail" ? Private Sub Application_Reminder(ByVal Item As Object) Dim objMsg As MailItem ' create new outgoing message Set objMsg = Application.CreateItem(olMailItem) ' your reminder notification address objMsg.To = " objMsg.CC = " objMsg.Subject = "Reminder: " & Item.Subject ' handle task items that generate reminders Select Case Item.Class Case olTask '48 objMsg.Body = _ "Start: " & Item.StartDate & vbCrLf & _ "End: " & Item.DueDate & vbCrLf & _ "Details: " & vbCrLf & Item.Body End Select ' send the message objMsg.Send Set objMsg = Nothing End Sub Paul "Eric Legault [MVP - Outlook]" wrote in message ... wFor starters, you couldn't automate this from an external .exe or script that starts Oultook and creates an e-mail message, as that's not supported. The Outlook Object Model is unsuitable to run in a Windows service: http://support.microsoft.com/default...b;en-us;237913 A server-side solution is best, but that involves creating an Exchange Event Sink and is very advanced. The best option is to create a recurring task and write VBA to trap the Reminder event to check that it is your defined task, then run your code to create and send an e-mail. -- Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration) Try Picture Attachments Wizard for Outlook: http://www.collaborativeinnovations.ca Blog: http://blogs.officezealot.com/legault/ "A+P" wrote: I'm running Outlook 2003 on Exchange 2003 server. I would like to schedule an automated email that will be send out to the same recipients with the same msg everyday from Mon-Fri in the morning. All I have so far is the following code. How do I tell Outlook to do this automatically every morning? Attribute VB_Name = "Module1" Option Explicit Sub SendMail() Dim olApp As Outlook.Application Dim olMail As Outlook.MailItem Dim blRunning As Boolean 'get application blRunning = True On Error Resume Next Set olApp = GetObject(, "Outlook.Application") If olApp Is Nothing Then Set olApp = New Outlook.Application blRunning = False End If On Error GoTo 0 Set olMail = olApp.CreateItem(olMailItem) With olMail 'Specify the email subject ..Subject = "Pick up the Mail" 'Specify who it should be sent to 'Repeat this line to add further recipients ..Recipients.Add ..Body = "This is today's pick up mail reminder." 'Choose which of the following 2 lines to have commented out ..Display 'This will display the message for you to check and send yourself '.Send ' This will send the message straight away End With If Not blRunning Then olApp.Quit Set olApp = Nothing Set olMail = Nothing End Sub Paul |
Automate Email
Close:
Dim objTask As Outlook.TaskItem If Item.Class = olTask Then Set objTask = Item objTask.Subject = "Pick Up Mail" Then End If Remember that the passed Item object could be a Contact, Appointment or MailItem that has a reminder flag on it, thus the check to make sure it is a Task. -- Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration) Try Picture Attachments Wizard for Outlook: http://www.collaborativeinnovations.ca Blog: http://blogs.officezealot.com/legault/ "A+P" wrote: Hi Eric, Ok, how's this? Dim TaskItem As Item.Class If TaskItem.Subject = "Pick Up Mail" Then ...... compose email and send... ...... End If Paul "Eric Legault [MVP - Outlook]" wrote in message ... Simple! The Item object passed an argument to the Reminder event can be casted to a TaskItem object where you have full access to all its properties (e.g. TaskItem.Subject, etc.). If it equals what you expect, run your code otherwise exit. -- Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration) Try Picture Attachments Wizard for Outlook: http://www.collaborativeinnovations.ca Blog: http://blogs.officezealot.com/legault/ "A+P" wrote: Hi Eric, Thanks for your reply. I do have a generic code that will send an email on all task reminder event notifications. But how do I change it so it traps an event with the subject line: "Pick Up Mail" ? Private Sub Application_Reminder(ByVal Item As Object) Dim objMsg As MailItem ' create new outgoing message Set objMsg = Application.CreateItem(olMailItem) ' your reminder notification address objMsg.To = " objMsg.CC = " objMsg.Subject = "Reminder: " & Item.Subject ' handle task items that generate reminders Select Case Item.Class Case olTask '48 objMsg.Body = _ "Start: " & Item.StartDate & vbCrLf & _ "End: " & Item.DueDate & vbCrLf & _ "Details: " & vbCrLf & Item.Body End Select ' send the message objMsg.Send Set objMsg = Nothing End Sub Paul "Eric Legault [MVP - Outlook]" wrote in message ... wFor starters, you couldn't automate this from an external .exe or script that starts Oultook and creates an e-mail message, as that's not supported. The Outlook Object Model is unsuitable to run in a Windows service: http://support.microsoft.com/default...b;en-us;237913 A server-side solution is best, but that involves creating an Exchange Event Sink and is very advanced. The best option is to create a recurring task and write VBA to trap the Reminder event to check that it is your defined task, then run your code to create and send an e-mail. -- Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration) Try Picture Attachments Wizard for Outlook: http://www.collaborativeinnovations.ca Blog: http://blogs.officezealot.com/legault/ "A+P" wrote: I'm running Outlook 2003 on Exchange 2003 server. I would like to schedule an automated email that will be send out to the same recipients with the same msg everyday from Mon-Fri in the morning. All I have so far is the following code. How do I tell Outlook to do this automatically every morning? Attribute VB_Name = "Module1" Option Explicit Sub SendMail() Dim olApp As Outlook.Application Dim olMail As Outlook.MailItem Dim blRunning As Boolean 'get application blRunning = True On Error Resume Next Set olApp = GetObject(, "Outlook.Application") If olApp Is Nothing Then Set olApp = New Outlook.Application blRunning = False End If On Error GoTo 0 Set olMail = olApp.CreateItem(olMailItem) With olMail 'Specify the email subject ..Subject = "Pick up the Mail" 'Specify who it should be sent to 'Repeat this line to add further recipients ..Recipients.Add ..Body = "This is today's pick up mail reminder." 'Choose which of the following 2 lines to have commented out ..Display 'This will display the message for you to check and send yourself '.Send ' This will send the message straight away End With If Not blRunning Then olApp.Quit Set olApp = Nothing Set olMail = Nothing End Sub Paul |
Automate Email
I see. Let me try this. Thanks.
Paul "Eric Legault [MVP - Outlook]" wrote in message ... Close: Dim objTask As Outlook.TaskItem If Item.Class = olTask Then Set objTask = Item objTask.Subject = "Pick Up Mail" Then End If Remember that the passed Item object could be a Contact, Appointment or MailItem that has a reminder flag on it, thus the check to make sure it is a Task. -- Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration) Try Picture Attachments Wizard for Outlook: http://www.collaborativeinnovations.ca Blog: http://blogs.officezealot.com/legault/ "A+P" wrote: Hi Eric, Ok, how's this? Dim TaskItem As Item.Class If TaskItem.Subject = "Pick Up Mail" Then ...... compose email and send... ...... End If Paul "Eric Legault [MVP - Outlook]" wrote in message ... Simple! The Item object passed an argument to the Reminder event can be casted to a TaskItem object where you have full access to all its properties (e.g. TaskItem.Subject, etc.). If it equals what you expect, run your code otherwise exit. -- Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration) Try Picture Attachments Wizard for Outlook: http://www.collaborativeinnovations.ca Blog: http://blogs.officezealot.com/legault/ "A+P" wrote: Hi Eric, Thanks for your reply. I do have a generic code that will send an email on all task reminder event notifications. But how do I change it so it traps an event with the subject line: "Pick Up Mail" ? Private Sub Application_Reminder(ByVal Item As Object) Dim objMsg As MailItem ' create new outgoing message Set objMsg = Application.CreateItem(olMailItem) ' your reminder notification address objMsg.To = " objMsg.CC = " objMsg.Subject = "Reminder: " & Item.Subject ' handle task items that generate reminders Select Case Item.Class Case olTask '48 objMsg.Body = _ "Start: " & Item.StartDate & vbCrLf & _ "End: " & Item.DueDate & vbCrLf & _ "Details: " & vbCrLf & Item.Body End Select ' send the message objMsg.Send Set objMsg = Nothing End Sub Paul "Eric Legault [MVP - Outlook]" wrote in message ... wFor starters, you couldn't automate this from an external .exe or script that starts Oultook and creates an e-mail message, as that's not supported. The Outlook Object Model is unsuitable to run in a Windows service: http://support.microsoft.com/default...b;en-us;237913 A server-side solution is best, but that involves creating an Exchange Event Sink and is very advanced. The best option is to create a recurring task and write VBA to trap the Reminder event to check that it is your defined task, then run your code to create and send an e-mail. -- Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration) Try Picture Attachments Wizard for Outlook: http://www.collaborativeinnovations.ca Blog: http://blogs.officezealot.com/legault/ "A+P" wrote: I'm running Outlook 2003 on Exchange 2003 server. I would like to schedule an automated email that will be send out to the same recipients with the same msg everyday from Mon-Fri in the morning. All I have so far is the following code. How do I tell Outlook to do this automatically every morning? Attribute VB_Name = "Module1" Option Explicit Sub SendMail() Dim olApp As Outlook.Application Dim olMail As Outlook.MailItem Dim blRunning As Boolean 'get application blRunning = True On Error Resume Next Set olApp = GetObject(, "Outlook.Application") If olApp Is Nothing Then Set olApp = New Outlook.Application blRunning = False End If On Error GoTo 0 Set olMail = olApp.CreateItem(olMailItem) With olMail 'Specify the email subject ..Subject = "Pick up the Mail" 'Specify who it should be sent to 'Repeat this line to add further recipients ..Recipients.Add ..Body = "This is today's pick up mail reminder." 'Choose which of the following 2 lines to have commented out ..Display 'This will display the message for you to check and send yourself '.Send ' This will send the message straight away End With If Not blRunning Then olApp.Quit Set olApp = Nothing Set olMail = Nothing End Sub Paul |
Automate Email
One more question Eric. Is there a way to change the code to also check to
only send the message when the Open button is clicked? I don't want the email to be sent when the Snooze or Dismiss buttons are clicked on the Reminder notice. Paul "Eric Legault [MVP - Outlook]" wrote in message ... Close: Dim objTask As Outlook.TaskItem If Item.Class = olTask Then Set objTask = Item objTask.Subject = "Pick Up Mail" Then End If Remember that the passed Item object could be a Contact, Appointment or MailItem that has a reminder flag on it, thus the check to make sure it is a Task. -- Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration) Try Picture Attachments Wizard for Outlook: http://www.collaborativeinnovations.ca Blog: http://blogs.officezealot.com/legault/ "A+P" wrote: Hi Eric, Ok, how's this? Dim TaskItem As Item.Class If TaskItem.Subject = "Pick Up Mail" Then ...... compose email and send... ...... End If Paul "Eric Legault [MVP - Outlook]" wrote in message ... Simple! The Item object passed an argument to the Reminder event can be casted to a TaskItem object where you have full access to all its properties (e.g. TaskItem.Subject, etc.). If it equals what you expect, run your code otherwise exit. -- Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration) Try Picture Attachments Wizard for Outlook: http://www.collaborativeinnovations.ca Blog: http://blogs.officezealot.com/legault/ "A+P" wrote: Hi Eric, Thanks for your reply. I do have a generic code that will send an email on all task reminder event notifications. But how do I change it so it traps an event with the subject line: "Pick Up Mail" ? Private Sub Application_Reminder(ByVal Item As Object) Dim objMsg As MailItem ' create new outgoing message Set objMsg = Application.CreateItem(olMailItem) ' your reminder notification address objMsg.To = " objMsg.CC = " objMsg.Subject = "Reminder: " & Item.Subject ' handle task items that generate reminders Select Case Item.Class Case olTask '48 objMsg.Body = _ "Start: " & Item.StartDate & vbCrLf & _ "End: " & Item.DueDate & vbCrLf & _ "Details: " & vbCrLf & Item.Body End Select ' send the message objMsg.Send Set objMsg = Nothing End Sub Paul "Eric Legault [MVP - Outlook]" wrote in message ... wFor starters, you couldn't automate this from an external .exe or script that starts Oultook and creates an e-mail message, as that's not supported. The Outlook Object Model is unsuitable to run in a Windows service: http://support.microsoft.com/default...b;en-us;237913 A server-side solution is best, but that involves creating an Exchange Event Sink and is very advanced. The best option is to create a recurring task and write VBA to trap the Reminder event to check that it is your defined task, then run your code to create and send an e-mail. -- Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration) Try Picture Attachments Wizard for Outlook: http://www.collaborativeinnovations.ca Blog: http://blogs.officezealot.com/legault/ "A+P" wrote: I'm running Outlook 2003 on Exchange 2003 server. I would like to schedule an automated email that will be send out to the same recipients with the same msg everyday from Mon-Fri in the morning. All I have so far is the following code. How do I tell Outlook to do this automatically every morning? Attribute VB_Name = "Module1" Option Explicit Sub SendMail() Dim olApp As Outlook.Application Dim olMail As Outlook.MailItem Dim blRunning As Boolean 'get application blRunning = True On Error Resume Next Set olApp = GetObject(, "Outlook.Application") If olApp Is Nothing Then Set olApp = New Outlook.Application blRunning = False End If On Error GoTo 0 Set olMail = olApp.CreateItem(olMailItem) With olMail 'Specify the email subject ..Subject = "Pick up the Mail" 'Specify who it should be sent to 'Repeat this line to add further recipients ..Recipients.Add ..Body = "This is today's pick up mail reminder." 'Choose which of the following 2 lines to have commented out ..Display 'This will display the message for you to check and send yourself '.Send ' This will send the message straight away End With If Not blRunning Then olApp.Quit Set olApp = Nothing Set olMail = Nothing End Sub Paul |
Automate Email
Sort of. You can't trap form events for the Reminder window itself. So
you'd need to wire up an Inspector Trapper (see http://archives.officezealot.com/leg...cles/2224.aspx) and check during Inspectors.Add whether this is the same item as the Item object that's passed in the Reminder event. Tricky, but possible. Then perhaps you can use the Inspector_Open or Inspector_Close event to send the e-mail when the Task is opened/closed. -- Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration) Try Picture Attachments Wizard for Outlook: http://www.collaborativeinnovations.ca Blog: http://blogs.officezealot.com/legault/ "A+P" wrote: One more question Eric. Is there a way to change the code to also check to only send the message when the Open button is clicked? I don't want the email to be sent when the Snooze or Dismiss buttons are clicked on the Reminder notice. Paul "Eric Legault [MVP - Outlook]" wrote in message ... Close: Dim objTask As Outlook.TaskItem If Item.Class = olTask Then Set objTask = Item objTask.Subject = "Pick Up Mail" Then End If Remember that the passed Item object could be a Contact, Appointment or MailItem that has a reminder flag on it, thus the check to make sure it is a Task. -- Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration) Try Picture Attachments Wizard for Outlook: http://www.collaborativeinnovations.ca Blog: http://blogs.officezealot.com/legault/ "A+P" wrote: Hi Eric, Ok, how's this? Dim TaskItem As Item.Class If TaskItem.Subject = "Pick Up Mail" Then ...... compose email and send... ...... End If Paul "Eric Legault [MVP - Outlook]" wrote in message ... Simple! The Item object passed an argument to the Reminder event can be casted to a TaskItem object where you have full access to all its properties (e.g. TaskItem.Subject, etc.). If it equals what you expect, run your code otherwise exit. -- Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration) Try Picture Attachments Wizard for Outlook: http://www.collaborativeinnovations.ca Blog: http://blogs.officezealot.com/legault/ "A+P" wrote: Hi Eric, Thanks for your reply. I do have a generic code that will send an email on all task reminder event notifications. But how do I change it so it traps an event with the subject line: "Pick Up Mail" ? Private Sub Application_Reminder(ByVal Item As Object) Dim objMsg As MailItem ' create new outgoing message Set objMsg = Application.CreateItem(olMailItem) ' your reminder notification address objMsg.To = " objMsg.CC = " objMsg.Subject = "Reminder: " & Item.Subject ' handle task items that generate reminders Select Case Item.Class Case olTask '48 objMsg.Body = _ "Start: " & Item.StartDate & vbCrLf & _ "End: " & Item.DueDate & vbCrLf & _ "Details: " & vbCrLf & Item.Body End Select ' send the message objMsg.Send Set objMsg = Nothing End Sub Paul "Eric Legault [MVP - Outlook]" wrote in message ... wFor starters, you couldn't automate this from an external .exe or script that starts Oultook and creates an e-mail message, as that's not supported. The Outlook Object Model is unsuitable to run in a Windows service: http://support.microsoft.com/default...b;en-us;237913 A server-side solution is best, but that involves creating an Exchange Event Sink and is very advanced. The best option is to create a recurring task and write VBA to trap the Reminder event to check that it is your defined task, then run your code to create and send an e-mail. -- Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration) Try Picture Attachments Wizard for Outlook: http://www.collaborativeinnovations.ca Blog: http://blogs.officezealot.com/legault/ "A+P" wrote: I'm running Outlook 2003 on Exchange 2003 server. I would like to schedule an automated email that will be send out to the same recipients with the same msg everyday from Mon-Fri in the morning. All I have so far is the following code. How do I tell Outlook to do this automatically every morning? Attribute VB_Name = "Module1" Option Explicit Sub SendMail() Dim olApp As Outlook.Application Dim olMail As Outlook.MailItem Dim blRunning As Boolean 'get application blRunning = True On Error Resume Next Set olApp = GetObject(, "Outlook.Application") If olApp Is Nothing Then Set olApp = New Outlook.Application blRunning = False End If On Error GoTo 0 Set olMail = olApp.CreateItem(olMailItem) With olMail 'Specify the email subject ..Subject = "Pick up the Mail" 'Specify who it should be sent to 'Repeat this line to add further recipients ..Recipients.Add ..Body = "This is today's pick up mail reminder." 'Choose which of the following 2 lines to have commented out ..Display 'This will display the message for you to check and send yourself '.Send ' This will send the message straight away End With If Not blRunning Then olApp.Quit Set olApp = Nothing Set olMail = Nothing End Sub Paul |
Automate Email
Hmm...I looked at your link on Inspector Trapper. It's very thoroughly
written. Now all I have to do is understand what you're trying to say..hahaha. Paul "Eric Legault [MVP - Outlook]" wrote in message ... Sort of. You can't trap form events for the Reminder window itself. So you'd need to wire up an Inspector Trapper (see http://archives.officezealot.com/leg...cles/2224.aspx) and check during Inspectors.Add whether this is the same item as the Item object that's passed in the Reminder event. Tricky, but possible. Then perhaps you can use the Inspector_Open or Inspector_Close event to send the e-mail when the Task is opened/closed. -- Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration) Try Picture Attachments Wizard for Outlook: http://www.collaborativeinnovations.ca Blog: http://blogs.officezealot.com/legault/ "A+P" wrote: One more question Eric. Is there a way to change the code to also check to only send the message when the Open button is clicked? I don't want the email to be sent when the Snooze or Dismiss buttons are clicked on the Reminder notice. Paul "Eric Legault [MVP - Outlook]" wrote in message ... Close: Dim objTask As Outlook.TaskItem If Item.Class = olTask Then Set objTask = Item objTask.Subject = "Pick Up Mail" Then End If Remember that the passed Item object could be a Contact, Appointment or MailItem that has a reminder flag on it, thus the check to make sure it is a Task. -- Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration) Try Picture Attachments Wizard for Outlook: http://www.collaborativeinnovations.ca Blog: http://blogs.officezealot.com/legault/ "A+P" wrote: Hi Eric, Ok, how's this? Dim TaskItem As Item.Class If TaskItem.Subject = "Pick Up Mail" Then ...... compose email and send... ...... End If Paul "Eric Legault [MVP - Outlook]" wrote in message ... Simple! The Item object passed an argument to the Reminder event can be casted to a TaskItem object where you have full access to all its properties (e.g. TaskItem.Subject, etc.). If it equals what you expect, run your code otherwise exit. -- Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration) Try Picture Attachments Wizard for Outlook: http://www.collaborativeinnovations.ca Blog: http://blogs.officezealot.com/legault/ "A+P" wrote: Hi Eric, Thanks for your reply. I do have a generic code that will send an email on all task reminder event notifications. But how do I change it so it traps an event with the subject line: "Pick Up Mail" ? Private Sub Application_Reminder(ByVal Item As Object) Dim objMsg As MailItem ' create new outgoing message Set objMsg = Application.CreateItem(olMailItem) ' your reminder notification address objMsg.To = " objMsg.CC = " objMsg.Subject = "Reminder: " & Item.Subject ' handle task items that generate reminders Select Case Item.Class Case olTask '48 objMsg.Body = _ "Start: " & Item.StartDate & vbCrLf & _ "End: " & Item.DueDate & vbCrLf & _ "Details: " & vbCrLf & Item.Body End Select ' send the message objMsg.Send Set objMsg = Nothing End Sub Paul "Eric Legault [MVP - Outlook]" wrote in message ... wFor starters, you couldn't automate this from an external .exe or script that starts Oultook and creates an e-mail message, as that's not supported. The Outlook Object Model is unsuitable to run in a Windows service: http://support.microsoft.com/default...b;en-us;237913 A server-side solution is best, but that involves creating an Exchange Event Sink and is very advanced. The best option is to create a recurring task and write VBA to trap the Reminder event to check that it is your defined task, then run your code to create and send an e-mail. -- Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration) Try Picture Attachments Wizard for Outlook: http://www.collaborativeinnovations.ca Blog: http://blogs.officezealot.com/legault/ "A+P" wrote: I'm running Outlook 2003 on Exchange 2003 server. I would like to schedule an automated email that will be send out to the same recipients with the same msg everyday from Mon-Fri in the morning. All I have so far is the following code. How do I tell Outlook to do this automatically every morning? Attribute VB_Name = "Module1" Option Explicit Sub SendMail() Dim olApp As Outlook.Application Dim olMail As Outlook.MailItem Dim blRunning As Boolean 'get application blRunning = True On Error Resume Next Set olApp = GetObject(, "Outlook.Application") If olApp Is Nothing Then Set olApp = New Outlook.Application blRunning = False End If On Error GoTo 0 Set olMail = olApp.CreateItem(olMailItem) With olMail 'Specify the email subject ..Subject = "Pick up the Mail" 'Specify who it should be sent to 'Repeat this line to add further recipients ..Recipients.Add ..Body = "This is today's pick up mail reminder." 'Choose which of the following 2 lines to have commented out ..Display 'This will display the message for you to check and send yourself '.Send ' This will send the message straight away End With If Not blRunning Then olApp.Quit Set olApp = Nothing Set olMail = Nothing End Sub Paul |
All times are GMT +1. The time now is 05:19 PM. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2006 OutlookBanter.com