PDA

View Full Version : Subejctline automation & verification



buster_gonad
06-04-2011, 06:53 AM
Hi All,

I currently have the following code on my outlook to place the word restricted in my e-mails if I forget.

What I would like to have is the code to prompt me that the word restricted is not there and ask me

Do I wish to insert restricted and send mail or Do I wish to send email without restricted

Private sub Application-Itemsend (by Val Item as object, Cancel as boolean
If (left (Trim(Item.subject, 11)) <> "restricted" then
Item.subject = "restricted" + item.subject

end if

end sub

Can anyone help on the dedvelopment journey as I am fairly new to VB

Thanking you all in advance

Buster

buster_gonad
06-05-2011, 06:30 AM
Hi,

Having done some quick reading I have had a go at answering my own question. As I am new to the art of VBA I am not sure if its codingly correct

Can anyone advise

Sub test()
Dim strMsg As String
Dim res As Integer
On Error Resume Next

'First checks the subject line for the word restricted'

If (Left(Trim(item.Subject), 11)) <> "Restricted" Then
'opens a message box prompt'
strMsg = "This email does not contain a restricted warning! Do you wish to send it with a warning?"
res = MsgBox(strMsg, vbYesNo + vbDefaultButton1, _
"Email Verification")
If res = vbYes Then
item.Subject = "Restricted" + Itemsubject
cancel = False

'so the email is sent with restriction'
Else
If res = vbNo Then

cancel = False

'so the email is sent without restricted in it'
End If
End If
End If

End Sub


:banghead: :dunno

JP2112
06-29-2011, 06:26 PM
Try this:

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

If UCase$(Left$(Trim$(Item.Subject), 10)) <> "RESTRICTED" Then
' ask if you want to add the word
Select Case MsgBox("Add 'Restricted' and send mail?", vbYesNoCancel)
Case vbYes ' add word
Item.Subject = "restricted " & Item.Subject
Case vbCancel ' stop
Cancel = True
End Select
End If

End Sub

buster_gonad
07-04-2011, 08:20 AM
JP,

thanks very much for you help.

I will try it at work next week and let you know

Regards

B