VBOffice

Remove the Quotation Marks from a Sender

Two examples for how to remove troublesome quotation marks or an apostrophe from an email address.

Last modified: 2016/01/05 | Accessed: 57.642  | #100
◀ Previous sample Next sample ▶

Content

OLKeeper OLKeeper
OLKeeper reliably prevents users from closing their Outlook window and thus possibly missing reminders or e-mails.

Remove an apostrophe from the recipient

Depending on how an address was passed to Outlook, sometimes it is enclosed in apostrophes, and it could happen that Outlook doesn't send that email. This macro removes such an address and then adds it correctly. It will be called automatically by Outlook when you're going to send a message.


tip  How to add macros to Outlook
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
  Dim Recips As Outlook.Recipients
  Dim R As Outlook.Recipient
  Dim Typ As Outlook.OlMailRecipientType
  Dim i As Long
  Dim ReplaceThis As String, ReplaceBy As String
  
  ReplaceThis = Chr(39)
  ReplaceBy = ""
  
  Set Recips = Item.Recipients
  For i = Recips.Count To 1 Step -1
    Set R = Recips(i)
    If InStr(R.Address, ReplaceThis) Then
      Typ = R.Type
      Recips.Remove i
      Set R = Recips.Add(Replace(R.Address, ReplaceThis, ReplaceBy))
      R.Type = Typ
      R.Resolve
    End If
  Next
End Sub
SAM SAM
Determine the "identity" of your emails. Set with SAM the sender and the folder folder for sent items with the help of rules.

Remove a quotation mark from the sender

Sometimes Outlook displays the name of the sender of an email in quotation marks, and sometimes it does not. So, if you group the view by sender, two different groups are shown although the emails came from the same sender.

The following script removes these quotation marks. Paste the code to the module 'ThisOutlookSession'. Select the email you want to edit in a folder, then launch the script by pressing alt+f8.

(The script requires Outlook 2007, or higher.)

Public Sub EditSenderNames()
  Dim Sel As Outlook.Selection
  Dim Item As Object
  Dim i&
  Dim ReplaceThis$, ReplaceBy$, PropertyName$
  Dim OldValue$, NewValue$

  ReplaceThis = Chr(34)
  ReplaceBy = ""

  'Property: Sender's name
  PropertyName = "http://schemas.microsoft.com/mapi/proptag/0x0042001F"

  Set Sel = Application.ActiveExplorer.Selection
  For i = 1 To Sel.Count
    Set Item = Sel(i)
    OldValue = Item.PropertyAccessor.GetProperty(PropertyName)
    NewValue = Replace(OldValue, ReplaceThis, ReplaceBy)
    If OldValue <> NewValue Then
      Item.PropertyAccessor.SetProperty PropertyName, NewValue
      Item.Save
    End If
  Next
End Sub
Category-Manager Category-Manager
With Category-Manager you can group your Outlook categories, share them with other users, filter a folder by category, automatically categorize new emails, and more. You can use the Addin even for IMAP.
email  Send a message