Outlook Solutions Archive

If you’ve enabled “auto format internet and network paths with hyperlinks” feature in Outlook, the email addresses will be auto formatted with “mailto” links, too. Now, if you want to batch remove all email links, you can use the way in this post.

Perhaps you have noticed that the internet paths and email addresses will be converted into hyperlinks automatically. It is because that Outlook is set to auto format the internet and network paths with hyperlinks by default, as shown in the following screenshot.

AutoFormat internet and network paths with hyperlinks

In reality, for most of the users, they merely hope to format network paths with hyperlinks. They don’t like to format email addresses with “mailto” hyperlinks. In this case, they long for a method to quickly remove all email links in batches. Now, in the followings, we will introduce such a method.

Batch Remove All Email Links in Outlook Message

  1. At first, launch Outlook program.
  2. Then, trigger VBA editor by clicking the “Visual Basic” button in “Developer” ribbon.
  3. Next, in the “Microsoft Visual Basic for Applications” window, copy the code below into an unused module.
Sub RemoveMailtoHyperlinks()
    Dim objMail As Outlook.MailItem
    Dim objMailDocument As Word.Document
    Dim objHyperlinks As Word.Hyperlinks
    Dim i As Long
    Dim objHyperlink As Word.Hyperlink
    Dim strLinkText, strLinkAddress As String
 
    'Get the mail
    Select Case Outlook.Application.ActiveWindow.Class
           Case olInspector
                Set objMail = ActiveInspector.CurrentItem
           Case olExplorer
                Set objMail = ActiveExplorer.Selection.Item(1)
    End Select
 
    Set objMailDocument = objMail.GetInspector.WordEditor
    Set objHyperlinks = objMailDocument.Hyperlinks
 
    If objHyperlinks.Count > 0 Then
       For i = objHyperlinks.Count To 1 Step -1
           Set objHyperlink = objHyperlinks.Item(i)
           strLinkText = objHyperlink.TextToDisplay
           strLinkAddress = objHyperlink.Address
 
           'Get the hyperlink of email address
           If InStr(strLinkText, "@") > 0 And Left(strLinkAddress, 7) = "mailto:" And InStr(strLinkText, "@") > 0 Then
 
              'Remove this hyperlink
              objHyperlink.Delete
           End If
       Next
    Else
       MsgBox "No Hyperlink!", vbExclamation + vbOKOnly
    End If
End Sub

VBA Code - Batch Remove All Email Links in Outlook Message

  1. After that, add this macro to Quick Access Toolbar or ribbon.
  2. Finally, you can have a try.
  • First off, compose an email which contains hyperlinks of network paths and email addresses, like the following screenshot.Sample Email
  • Then, click the macro button.
  • When macro completes, as you can see, the “mailto” hyperlinks of email addresses have been removed.Batch Removed Email Links in Message

Watch Out for Unknown Links

You must have ever received the emails which have a lot of hyperlinks in body. If this email is from an unknown sender or its hyperlinks are in unknown domains, you should never readily open the links. It is because that they may be malicious. Once you open them, your Outlook file and even the whole computer can be virus infected. At that time, it is too late to regret. What you can do is to first kill viruses by antivirus software and then resort to a remarkable Outlook recovery tool to fix Outlook file, such as DataNumen Outlook Repair.

Author Introduction:

Shirley Zhang is a data recovery expert in DataNumen, Inc., which is the world leader in data recovery technologies, including damaged mdf and outlook repair software products. For more information visit www.datanumen.com

Be the first to comment

If you have a rule whose condition is “with specific words in the subject” and often want to add an email’ subject to this condition, you can use the method in this post. It can let you quickly get it without needs to find and change this rule manually.

Perhaps you’ve created an Outlook rule which will automatically do something with the emails whose subjects contain specific words. Now, you want to add the subjects of some emails to this rule condition. In general, you have to first write down the subjects and then open “Rules and Alerts” dialog box to change the rule condition manually. Apparently, it is quite troublesome. If you frequently add the new subjects to this rule’s condition, you can use the following way, which is very efficient.Sample Rule

Add the Subjects of Multiple Emails to the Condition of a Specific Rule

  1. To begin with, start Outlook program.
  2. Then, get access to Outlook VBA editor via tapping “Alt + F11”.
  3. Next, in the new window, put the code below into a module.
Sub AddSubjectsOfMultipleEmailsToConditionSpecificRule()
    Dim objSelection As Outlook.Selection
    Dim objMail As Outlook.MailItem
    Dim objDictionary As Object
    Dim objRules As Outlook.Rules
    Dim objSpecificRule As Outlook.Rule
    Dim objRuleCondition As Outlook.RuleCondition
    Dim objTextRuleCondition As Outlook.TextRuleCondition
    Dim strTextArray As Variant
    Dim varSubjects As Variant
    Dim varNewTextArray As Variant
 
    'Get the selected emails
    Set objSelection = Outlook.Application.ActiveExplorer.Selection
    Set objDictionary = CreateObject("Scripting.Dictionary")
 
    For Each objItem In objSelection
        If TypeOf objItem Is MailItem Then
           Set objMail = objItem
           If objDictionary.Exists(LCase(objMail.Subject)) = False Then
              objDictionary.Add LCase(objMail.Subject), 1
           End If
        End If
    Next
 
    'Get the specific rule, change the rule name as per your own case
    Set objRules = Outlook.Application.Session.DefaultStore.GetRules
    Set objSpecificRule = objRules.Item("Auto Flag Mails with Specific Texts in Subjects")
 
    'Add the subjects to the rule condition
    For Each objRuleCondition In objSpecificRule.Conditions
        If objRuleCondition.ConditionType = olConditionSubject Then
           If objRuleCondition.Enabled = True Then
              Set objTextRuleCondition = objRuleCondition
              strTextArray = objTextRuleCondition.Text
              varSubjects = objDictionary.Keys
  
              varNewTextArray = Split(Join(strTextArray, ",") & "," & Join(varSubjects, ","), ",")
 
              objTextRuleCondition.Text = varNewTextArray
           End If
        End If
    Next
 
    objRules.Save
    MsgBox "Complete!", vbInformation + vbOKOnly
End Sub

VBA Code - Add the Subjects of Multiple Emails to the Condition of a Specific Rule

  1. After that, for future convenience, add this macro to Quick Access Toolbar or ribbon by referring to “Optional Step” in “How to Run VBA Code in Your Outlook“.
  2. Finally, exit VBA editor and have a try.
  • First off, select the emails whose subjects you want to add to the rule.
  • Then, click the newly added macro button.Run Macro on Selected Mails
  • After macro finishes, go to “File” menu and click “Manage Rules & Alerts” button.
  • In the “Rules and Alerts” dialog, pitch on the specific rule to check its condition. You can see that the email subjects have been in the condition.Newly Added Words in Rule Condition

Protect Your Outlook Data

Though Outlook is admittedly vulnerable, you still can make enough precautions to safeguard your Outlook data from loss. Above all, you ought to regularly back up your PST files. In this way, even if Outlook is corrupted, you can easily recover PST data from backups. Yet, if you have no backup, you still have a choice. That is to take recourse to a robust PST fix utility, such as DataNumen Outlook Repair.

Author Introduction:

Shirley Zhang is a data recovery expert in DataNumen, Inc., which is the world leader in data recovery technologies, including corrupted mdf and outlook repair software products. For more information visit www.datanumen.com

Be the first to comment

If you need to count the inbox emails by sender domain, it is too stupid to figure out the domain of each email and then count one by one. It is highly suggested to utilize the 2 methods introduced in this article.

Perhaps you have received a great number of emails in Inbox. Thereby, now, you want to count them. Maybe not only do you want to get a total count, but also you would like to count the inbox emails by sender domain. Here we will introduce 2 methods to quickly get the counts by sender domain.

Method 1: Get Count after Grouping Emails by Sender Domain

  1. For a start, trigger VBA editor according to “How to Run VBA Code in Your Outlook“.
  2. Then, put the VBA code below into a module.
Sub GetSenderDomain()
    Dim objInboxItems As Outlook.Items
    Dim i As Long
    Dim objMail As Outlook.MailItem
    Dim objDomainProperty As Outlook.UserProperty
    Dim strSenderAddress, strSenderDomain As String
 
    Set objInboxItems = Outlook.Application.Session.GetDefaultFolder(olFolderInbox).Items
 
    For i = objInboxItems.Count To 1 Step -1
        If TypeOf objInboxItems(i) Is MailItem Then
           Set objMail = objInboxItems(i)
 
           Set objDomainProperty = objMail.UserProperties.Find("Domain", True)
           If objDomainProperty Is Nothing Then
              Set objDomainProperty = objMail.UserProperties.Add("Domain", olText, True)
           End If
 
           strSenderAddress = objMail.SenderEmailAddress
           strSenderDomain = Right(strSenderAddress, Len(strSenderAddress) - InStr(strSenderAddress, "@"))
 
           objDomainProperty.Value = strSenderDomain
           objMail.Save
        End If
    Next
End Sub

VBA Code - Get Sender Domain

  1. Next, open Inbox and go to “View” tab and click “View Settings”.
  2. In popup dialog, click “Group By”.
  3. Then, in the subsequent dialog box, uncheck “Automatically group according to arrangement”.
  4. After that, choose “User-defined fields in Inbox” from the dropdown list of “Select available fields from”.
  5. Later, select “Domain” in “Group items by”.Group Inbox Emails by Sender Domain
  6. Lastly, click a series of “OK” to save the changed view settings.
  7. Now, in Inbox, when hovering cursor above a group header, you can see the email count of the specific sender domain, like the following figure.Get Count in Email Group Header

Method 2: Count by Sender Domain Directly via VBA

  1. To begin with, in Outlook VBA editor, copy the following code into a module.
Sub CountInboxEmailsbySenderDomain()
    Dim objDictionary As Object
    Dim objInbox As Outlook.Folder
    Dim i As Long
    Dim objMail As Outlook.MailItem
    Dim strSenderAddress As String
    Dim strSenderDomain As String
    Dim varSenderDomains As Variant
    Dim varItemCounts As Variant
    Dim strMsg As String
 
    Set objDictionary = CreateObject("Scripting.Dictionary")
    Set objInbox = Outlook.Application.Session.GetDefaultFolder(olFolderInbox)
 
    For i = objInbox.Items.Count To 1 Step -1
        If objInbox.Items(i).Class = olMail Then
           Set objMail = objInbox.Items(i)
 
           strSenderAddress = objMail.SenderEmailAddress
           strSenderDomain = Right(strSenderAddress, Len(strSenderAddress) - InStr(strSenderAddress, "@"))
 
           If objDictionary.Exists(strSenderDomain) Then
              objDictionary(strSenderDomain) = objDictionary(strSenderDomain) + 1
           Else
              objDictionary.Add strSenderDomain, 1
           End If
        End If
    Next
 
    varSenderDomains = objDictionary.Keys
    varItemCounts = objDictionary.Items
 
    For i = LBound(varSenderDomains) To UBound(varSenderDomains)
        strMsg = varSenderDomains(i) & vbTab & varItemCounts(i) & vbCrLf & strMsg
    Next
 
    MsgBox "Inbox Email Count by Sender Domain: " & vbCrLf & vbCrLf & strMsg, vbInformation + vbOKOnly
End Sub

VBA Code - Count Inbox Emails by Sender Domain

  1. Eventually, press “F5” key button.
  2. At once, you’ll receive the message prompting of the email counts by sender domain, as shown in the screenshot below.Message Prompting Email Counts

Escape from PST Data Loss

Since Outlook PST file contains all the items in your Outlook, you definitely don’t want to lose it. Hence, you have to firstly back up the file at regular intervals. Also, you should know how to find and launch Scanpst to repair Outlook file. Of course, since the inbuilt tool is unable to make effects in many cases, you had better get hold of a powerful external tool, such as DataNumen Outlook Repair.

Author Introduction:

Shirley Zhang is a data recovery expert in DataNumen, Inc., which is the world leader in data recovery technologies, including mdf recovery and outlook repair software products. For more information visit www.datanumen.com

Be the first to comment