r0b0tz
music, art, parties, technology, code

One of my supervisors likes to send out tons of emails with absolutely no subject… he uses Outlook, so today I had enough and wrote this little VBA gem:

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
If TypeName(Item) <> “MailItem” Then Exit Sub
If Len(Trim(Item.Subject)) = 0 Then
Dim splitItem As Variant
Dim s As String
s = Replace(Item.Body, vbCrLf, ““”)
splitItem = Split(s, ““”)
s = splitItem(0)
Item.Subject = s + “…”
Cancel = False
End If
End Sub

Just install it into your default VBA project (ALT-F11 in Outlook, expand the project tree on the left until you see “ThisOutlookSession”, double click that, paste and save!

Note: for some reason Split wouldn’t recognize a vbCr, so I had to replace the vbCrLf with another character.



Leave a comment or two

Name (required)

Email (required)

Website

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Feel free to leave a comment

Log in