mrmmickle1
Member
- Outlook version
- Outlook 2010 64 bit
- Email Account
- Office 365 Exchange
I have created a custom form that I use to document Reporting Categories.
These Categories are then concatenated and put into a UserProperty.
I would like to then use the Application_ItemSend Event in order to perform something similar to the following rule:
Apply the rule after I send the message with ‡ in the body and on this computer only move a copy to the Deliverable Folder
Note: I was initially concatenating the fields in my form into the body of the email like this....which actually worked... I would rather save these to a UserProperty in the mailItem so they are not visible. Initially this had worked when appending the "USERINPUT" to the end of the email.... until we encountered emails exceeding 32,767 the max allowable characters. In this case the above rule will not process..... So then I appended the "USERINPUT" to the front of the email which works fine .....however, I feel this is a sloppy method.
My Issue is that I want to perform a rule that is like this:
Apply the rule after I send the message when UserProperty("XYZ") Exists and on this computer only move a copy to the Deliverable Folder
I tried to do this with the following code. However, it freezes the Application when I have large attachments.
I was wondering if there is a better way to accomplish this task....seeing as this issue doesn't seem to occur if I use an outlook rule. So I guess I am trying to figure out the code that the Outlook Rule is using to move the copy....seeing as this works without issue.
Here is my UserForm Code:
Thank you for your time.
These Categories are then concatenated and put into a UserProperty.
I would like to then use the Application_ItemSend Event in order to perform something similar to the following rule:
Apply the rule after I send the message with ‡ in the body and on this computer only move a copy to the Deliverable Folder
Note: I was initially concatenating the fields in my form into the body of the email like this....which actually worked... I would rather save these to a UserProperty in the mailItem so they are not visible. Initially this had worked when appending the "USERINPUT" to the end of the email.... until we encountered emails exceeding 32,767 the max allowable characters. In this case the above rule will not process..... So then I appended the "USERINPUT" to the front of the email which works fine .....however, I feel this is a sloppy method.
Code:
'Input Report Specifications to end of email
myText = "<font size= 1><font color=""White"">‡" _
& Me.cboLOB & "‡" _
& Me.cboSubLOB & "‡" _
& Me.cboDelType _
& "</font></font size>"
My Issue is that I want to perform a rule that is like this:
Apply the rule after I send the message when UserProperty("XYZ") Exists and on this computer only move a copy to the Deliverable Folder
I tried to do this with the following code. However, it freezes the Application when I have large attachments.
Code:
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
Dim fld As UserProperty
Dim saveFldr As Folder
Dim cpyMail As MailItem
Set saveFlder = Application.GetNamespace("MAPI").Folders("HR Data Requests").Folders("New and Open Requests").Folders("Deliverable Tracking")
For Each fld In Item.UserProperties
If fld.Name = "CDTReporting" Then
Set cpyMail = Item.Copy
cpyMail.Move saveFldr
End If
Next fld
End Sub
I was wondering if there is a better way to accomplish this task....seeing as this issue doesn't seem to occur if I use an outlook rule. So I guess I am trying to figure out the code that the Outlook Rule is using to move the copy....seeing as this works without issue.
Here is my UserForm Code:
Code:
Private Sub cmdSendMail_Click()
Dim myText As String
Dim cpyFolder As Outlook.Folder
Dim sntFolder As Outlook.Folder
Dim cpy As Object
Dim NewMail As MailItem
Dim oInspector As Inspector
Dim myUserProperty As UserProperty
'Set Mail Object
Set oInspector = Application.ActiveInspector
If oInspector Is Nothing Then
MsgBox "No active inspector item present.", vbCritical, "MetLife - CDT Tracker"
Exit Sub
End If
'Set Mail Item
Set NewMail = oInspector.CurrentItem
'Make Sure Email is Editable
If NewMail.Sent Then
MsgBox "This is not an editable email"
Exit Sub
End If
'Check for Subject Line and Recipient
If NewMail.Subject = "" Or _
NewMail.To = "" Then
MsgBox "Please Enter a Subject Line or Recipient(s)", vbCritical, "MetLife - CDT Tracker"
Exit Sub
End If
'Ensure Reporting Data has been filled in accurately
If Me.cboLOB = "" Or _
Me.cboSubLOB = "" Or Me.cboSubLOB = "Please Select LOB" Or _
Me.cboDelType = "" Then
MsgBox "Please fill in all reporting fields. They are mandatory!", vbCritical, "MetLife - CDT Tracker"
Exit Sub
End If
'Input Report Specifications to end of email
myText = "<font size= 1><font color=""White"">‡" _
& Me.cboLOB & "‡" _
& Me.cboSubLOB & "‡" _
& Me.cboDelType _
& "</font></font size>"
Set myUserProperty = NewMail.UserProperties.Add("CDTReporting", olText)
myUserProperty.Value = "Test Test Test"
'Add Report Tracking Info to Email
If oInspector.IsWordMail Then
NewMail.HTMLBody = myText & NewMail.HTMLBody
Else
'No object model to work with. Must manipulate raw text.
Select Case NewMail.BodyFormat
Case olFormatPlain, olFormatRichText, olFormatUnspecified
NewMail.Body = myText & NewMail.Body
Case olFormatHTML
NewMail.HTMLBody = "<p>" & myText & "</p>" & NewMail.HTMLBody
End Select
End If
Unload Me 'Unload usrfrmCDT
NewMail.Send 'Send Active Outlook Message
End Sub
Thank you for your time.