Create Calendar Alert Event form Mail Subject line?

Status
Not open for further replies.

Jatin

New Member
Outlook version
Outlook 2013 64 bit
Email Account
Exchange Server 2013
Hi there,

What I am trying to do is create an calendar event from mail subject line as below.
If I receive any mail with subject line as Due Date:01/01/2015 it should create a event in calendar and also alert me whenever that date and time occurs.
Is this possible by rule or macro? Any help would be much appreciated.

Thanks,
Jatin
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
You can't use a rule by itself, but can use a script with a rule to find messages which might match then process it more with a script. A regex example is here: http://www.slipstick.com/developer/run-a-script-rule-autoreply-using-a-template/

I didn't test it, but this should be close:
Code:
Sub ConvertMailtoTask(Item As Outlook.MailItem)
Dim objAppt As Outlook.appointmentItem
Dim Reg1 As Object
Dim M1 As Object
Dim M As Object
Dim strDate
Set Reg1 = CreateObject("VBScript.RegExp")

With Reg1
.Pattern = "Due Date[:]([\d/]*)"
End With

If Reg1.Test(Item.Subject) Then

Set M1 = Reg1.Execute(Item.Subject)
For Each M In M1
strDate = M.SubMatches(0)
Next
End If

Set objAppt = Application.CreateItem(olappointmentItem)
With objAppt
.Subject = Item.Subject
.StartDate = strdate
.Body = Item.Body
.ReminderSet = True
.ReminderTime = strdate
.Save
End With
Set objappt = Nothing
End Sub
 

Jatin

New Member
Outlook version
Outlook 2013 64 bit
Email Account
Exchange Server 2013
Thanks Diane for the quick reply.
Sorry small change in the question. Actaully date comes in Message Body and in below format.
The bla blaa milestone is due in 2 days on Friday, 27 February 2015.

Can we do this using above script.

Regards,
Jatin

You can't use a rule by itself, but can use a script with a rule to find messages which might match then process it more with a script. A regex example is here: http://www.slipstick.com/developer/run-a-script-rule-autoreply-using-a-template/

I didn't test it, but this should be close:
Code:
Sub ConvertMailtoTask(Item As Outlook.MailItem)
Dim objAppt As Outlook.appointmentItem
Dim Reg1 As Object
Dim M1 As Object
Dim M As Object
Dim strDate
Set Reg1 = CreateObject("VBScript.RegExp")

With Reg1
.Pattern = "Due Date[:]([\d/]*)"
End With

If Reg1.Test(Item.subject) Then

Set M1 = Reg1.Execute(Item.Body)
For Each M In M1
strDate = M.SubMatches(0)
Next
End If

Set objAppt = Application.CreateItem(olappointmentItem)
With objAppt
.Subject = Item.Subject
.StartDate = strdate
.Body = Item.Body
.ReminderSet = True
.ReminderTime = strdate
.Save
End With
Set objappt = Nothing
End Sub
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
As long as you can get a unique pattern, you can do it.

This is where we grab and process the date:
With Reg1
.Pattern = "Due Date[:]([\d/]*)"
End With

If Reg1.Test(Item.Subject) Then

Set M1 = Reg1.Execute(Item.Subject)
For Each M In M1
strDate = M.SubMatches(0)
Next

you need to change the pattern - as long as only the date and day count change, you can do this.
milestone is due in 2 days on Friday, 27 February 2015.

one option is
.Pattern = "milestone is due in ([\d/]*) days"
then add it to date or now to get the start (or due) date.

.StartDate = date + strdate

that might be easier than grabbing the date.

Updated;: you also need to change Item.Subject to Item.body in the Reg1 lines.
 

Jatin

New Member
Outlook version
Outlook 2013 64 bit
Email Account
Exchange Server 2013
Thanks Diane,

Now my code looks as below if I am reading date from mail body not subject


Sub ConvertMailtoTask(Item As Outlook.MailItem)
Dim objAppt As Outlook.AppointmentItem
Dim Reg1 As Object
Dim M1 As Object
Dim M As Object
Dim strDate
Set Reg1 = CreateObject("VBScript.RegExp")

With Reg1
.Pattern = "milestone is due in ([\d/]*) days"
End With

If Reg1.Test(Item.Body) Then

Set M1 = Reg1.Execute(Item.Body)
For Each M In M1
strDate = M.SubMatches(0)
Next
End If

Set objAppt = Application.CreateItem(olAppointmentItem)
With objAppt
.Subject = Item.Subject
.StartDate = Date + strDate
.Body = Item.Body
.ReminderSet = True
.ReminderTime = strDate
.Save
End With
Set objAppt = Nothing
End Sub
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
D Can Exchange Admin Center create a pst for users email/contacts/calendar? Exchange Server Administration 0
D Outlook macros to create meeting on shared calendar Outlook VBA and Custom Forms 10
A VBA to create meeting from template from a time slot selected in someone's calendar Outlook VBA and Custom Forms 5
M Automatically create event in calendar when task is created Outlook VBA and Custom Forms 1
T Create custom calendar entry form... Outlook VBA and Custom Forms 3
P Possibility to create a calendar button "remaining week"??? Using Outlook 3
M Create an Appointment from XL Spreadsheet in a Shared Calendar. Outlook VBA and Custom Forms 1
A Create a Company Calendar Using Outlook 1
anoble1 How to create an email with a link to add a calendar appointment Using Outlook 1
I how to create appointment using saved template onto public folder shared calendar Using Outlook 3
A Suggestions on ways to let apps create appointments in any user's calendar? Exchange Server Administration 0
A Outlook 2010 trying to create calendar/task entries generates error "Could not save item.The connect Using Outlook 2
N How Can I create an Outlook Macro to import calendar? Outlook VBA and Custom Forms 1
P Create appointment to custom (shared) outlook calendar Outlook VBA and Custom Forms 3
M How create a Rule to filter sender's email with more that one @ sign Using Outlook 1
B Can I create a local PST file for SPAM on a drive that is usually disconnected? Using Outlook 3
Chiba Create an appointment for all the members Outlook VBA and Custom Forms 1
S Create a clickable custom column field Outlook VBA and Custom Forms 0
O Create a custom contact form - questions before messing things up... Outlook VBA and Custom Forms 4
C Can't create Outlook data file Outlook Wishlist 0
L automaticaly create a teams meeting with a sync Using Outlook 0
S Create A Search Folder That Looks For Message Class? Outlook VBA and Custom Forms 0
F How to create phone number as links in notes of Contacts Using Outlook 2
Nessa Can't create new appointment Using Outlook 1
A Create date folder and move messages daily Outlook VBA and Custom Forms 1
C Create new Message with shared contacts & BCC'ing recipients Outlook VBA and Custom Forms 0
O Multiple email accounts - hesitate to create a new profile Using Outlook 3
G Can't create Folder Groups in Outlook 2013 Using Outlook 0
N Outlook rules don't create a copy for bcc'ed emails Using Outlook 3
F Delete/create/reset Exchange mailbox on Outlook.com Using Outlook.com accounts in Outlook 3
R Can not create folder to store specific emails in in Outlook for Mac Using Outlook 1
W Create Search Folder excluding Specific Email Addresses Using Outlook 5
A Outlook macro to create search folder with mail categories as criteria Outlook VBA and Custom Forms 3
K VBA BeforeItemMove event create rule to always move to its folder. Outlook VBA and Custom Forms 4
JackBlack What tools do you use to create the signature for email? Using Outlook 3
Rupert Dragwater How to create a new email with @outlook.com Using Outlook.com accounts in Outlook 32
F Should a new email account also create new contacts Using Outlook 2
D create an html table in outlook custom form 2010 using vba in MsAccess Outlook VBA and Custom Forms 7
R Outlook add-in to create new contact from an email. Using Outlook 0
Tanja Östrand Outlook 2016 - Create Macro button to add text in Subject Outlook VBA and Custom Forms 1
Q Script to create a pst file for Archiving Using Outlook 1
Jennifer Murphy Can I create a Rule with Or'd conditions? Using Outlook 1
G How do I create a custom pick list in VB for an outlook automated email? Outlook VBA and Custom Forms 1
L Create Custom Form Using Outlook 0
Diane Poremsky Create a Task when a Message is Flagged New Slipstick.com Articles 0
Stilgar Relsik Create a rule to copy text from an email and paste it in the subject line. Using Outlook 1
Diane Poremsky Create a custom field for Outlook messages New Slipstick.com Articles 0
Mark White vba to create a shared mailbox folder Outlook VBA and Custom Forms 3
Diane Poremsky Automatically create a task when sending a message New Slipstick.com Articles 0
Diane Poremsky Create a Custom Numbering Field for Outlook messages New Slipstick.com Articles 0

Similar threads

Top