PDA

View Full Version : auto subject help needed.



martindixon
04-01-2014, 11:14 AM
I have two separate macros that I would like to join together but have no idea how to do it.

The first is to auto populate the date and name before the subject text. The second one when you click on send comes up with a box asking if you would like to send as encrypted, if yes is selected it puts encrypt at the start of the subject. if no is clicked then still have the date at the start.



Private Sub Application_ItemSend(ByVal ITEM As Object, Cancel As Boolean)

If Left(ITEM.Subject, 4) = Format(Now(), "yyyymm") Or Left(ITEM.Subject, 3) = "FW:" Or Left(ITEM.Subject, 3) = "RE:" Then
Else
ITEM.Subject = Format(Now(), "yyyymmdd-") & “ME" & Replace(ITEM.Subject, " ", "_")
End If

End Sub





Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
dim msg as string

msg =
Select Case MsgBox("Would you like to Encrypt this message?", vbYesNoCancel + vbQuestion + vbMsgBoxSetForeground, Item.Subject)


Case Is = vbYes
Set olkMsg = Outlook.Application.ActiveInspector.CurrentItem
olkMsg.Subject = "encrypt" & olkMsg.Subject
Set olkMsg = Nothing

Case Is = vbNo
Cancel = False

Case Is = vbCancel
Cancel = True

End Select

End Sub

westconn1
04-01-2014, 01:18 PM
try

Private Sub Application_ItemSend(ByVal ITEM As Object, Cancel As Boolean)

If Left(ITEM.Subject, 4) = Format(Now(), "yyyymm") Or Left(ITEM.Subject, 3) = "FW:" Or Left(ITEM.Subject, 3) = "RE:" Then
Else
ITEM.Subject = Format(Now(), "yyyymmdd-") & “ME" & Replace(ITEM.Subject, " ", "_")
End If
Select Case MsgBox("Would you like to Encrypt this message?", vbYesNoCancel + vbQuestion + vbMsgBoxSetForeground, Item.Subject)
Case Is = vbYes
item.Subject = "encrypt" & olkMsg.Subject
' Case Is = vbNo
' Cancel = False not required
Case Is = vbCancel
Cancel = True
End Select

End Sub

martindixon
04-01-2014, 01:24 PM
Thank you

martindixon
04-01-2014, 11:57 PM
I'm getting a syntax error on

ITEM.Subject = Format(Now(), "yyyymmdd-") & “ME" & Replace(ITEM.Subject, " ", "_")

any ideas?

westconn1
04-02-2014, 03:26 AM
i tested
ITEM.Subject = Format(Now(), "yyyymmdd-") & "ME" & Replace(ITEM.Subject, " ", "_")
no error

watch for invalid " characters when pasting