Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Jul 23rd, 2012  |  syntax: VisualBasic  |  size: 1.66 KB  |  views: 325  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1.  
  2. 'Adds a link to the currently selected message to the clipboard
  3. Sub AddLinkToMessageInClipboard()
  4.     Dim objMail As Object
  5.     'was earlier Outlook.MailItem
  6.    Dim doClipboard As New DataObject
  7.     Dim message As String
  8.      
  9.     'One and ONLY one message muse be selected
  10.    If Application.ActiveExplorer.Selection.Count <> 1 Then
  11.         MsgBox ("Select one and ONLY one message.")
  12.         Exit Sub
  13.     End If
  14.    
  15.     Set objMail = Application.ActiveExplorer.Selection.Item(1)
  16.    
  17.     If objMail.Class = olMail Then
  18.         doClipboard.SetText "[[outlook:" + objMail.EntryID + "][MESSAGE: " + objMail.Subject + " (" + objMail.SenderName + ")]]"
  19.     ElseIf objMail.Class = olAppointment Then
  20.         doClipboard.SetText "[[outlook:" + objMail.EntryID + "][MEETING: " + objMail.Subject + " (" + objMail.Organizer + ")]]"
  21.     ElseIf objMail.Class = olTask Then
  22.         doClipboard.SetText "[[outlook:" + objMail.EntryID + "][TASK: " + objMail.Subject + " (" + objMail.Owner + ")]]"
  23.     ElseIf objMail.Class = olContact Then
  24.         doClipboard.SetText "[[outlook:" + objMail.EntryID + "][CONTACT: " + objMail.Subject + " (" + objMail.FullName + ")]]"
  25.     ElseIf objMail.Class = olJournal Then
  26.         doClipboard.SetText "[[outlook:" + objMail.EntryID + "][JOURNAL: " + objMail.Subject + " (" + objMail.Type + ")]]"
  27.     ElseIf objMail.Class = olNote Then
  28.         doClipboard.SetText "[[outlook:" + objMail.EntryID + "][NOTE: " + objMail.Subject + " (" + " " + ")]]"
  29.     Else
  30.         doClipboard.SetText "[[outlook:" + objMail.EntryID + "][ITEM: " + objMail.Subject + " (" + objMail.MessageClass + ")]]"
  31.     End If
  32.    
  33.     doClipboard.PutInClipboard
  34.    
  35. End Sub