Hi All,

I was hoping for some help, I've got myself confused...

BASIC CONCEPT

  • Email comes into inbox, macro runs off _ItemAdd, mail gets categorized based on some keywords & reminder set for 7 days later (this part working fine!).
  • Then when relevant category reminder fires, original email item from inbox displays AND userform appears over the top with 3 command buttons.
  • (For instance) 1 of these command buttons should create a new email from template, make original email item an attachment, assign "to" field based on original email & do some changes to email body.


PROBLEM
The user form doesn't load on Application_Reminder & when compiling I get "Compile error: argument not optional" on the UserForm code (which does nothing but attempt to call the macro in module 1).

I'm having trouble working out which module each macro should go into. I had it working fine previously with a msgbox & a VBYes/VBNo button, as I could just build an if yes/ if no directly into the THISOUTLOOKSESSION routine & it remembered all the references to the original email item etc. But I needed 3 buttons, not 2 & I liked being able to use a more design friendly user form.

I get the feeling the macro in module 1 can't find reference to the original email item? Do I need the code in module 1 or can I run it directly from the userform?


THIS OUTLOOK SESSION
Public Sub Application_Reminder(ByVal Item As Object)
Dim objFollowUpMail As Outlook.MailItem


If Item.Categories = "Dunning" Then
Item.Display
UserForm1.Show
End If
End Sub


USERFORM1
Public Sub CommandButton1_Click()
ButtonClick_Yes
End Sub

Public Sub CommandButton2_Click()
ButtonClick_No
End Sub

Public Sub CommandButton3_Click()
ButtonClick_Dismiss
End Sub


MODULE1
Public Sub ButtonClick_Yes(ByVal Item As Object)
Dim objFollowUpMail As Outlook.MailItem


Set objFollowUpMail = Application.CreateItemFromTemplate("Example.oft")
With objFollowUpMail
.To = Item.Recipients.Item(1).Address
.Subject = "Follow Up: " & Chr(34) & Item.Subject & Chr(34)
.Attachments.Add Item
.HTMLBody = "Example"
.Display
End With
End Sub



Any help, would be really appreciated! Many thanks.