How to Send Plain Text Emails Only to Those in a Specific Domain via Outlook VBA

Some users would like to send Plain Text emails only to the recipients whose email addresses are in a specific domain. This article will introduce a smart method to get it.

In my previous article “How to Always Send Outlook Emails in Plain Text Format for Specific Contacts”, you can get 2 approaches to send Plain Text emails only to specific contacts. If you want to send such emails to all contacts in a specific mail domain, using the 2 ways in that article will be a little bit stupid and troublesome. Hence, here we will share you another way, which is much more effective.

Send Plain Text Emails Only to Those in a Specific Domain via Outlook VBA

Send Plain Text Emails Only to Those in a Specific Domain

  1. First of all, you should launch your Outlook application.
  2. Then, you need to press “Alt + F11” key buttons in the Outlook main screen.
  3. Next, the “Microsoft Visual Basic for Applications” window will turn up. In it, you ought to open the “ThisOutlookSession” project.
  4. Subsequently, copy and paste the following VBA code into this project.
'Occurs when sending an Outlook email
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
    Dim objMail As Outlook.MailItem
    Dim objRecipient As Outlook.recipient
    Dim strAddress, strDomain As String
 
    If TypeOf Item Is MailItem Then
       Set objMail = Item
       For Each objRecipient In objMail.Recipients
           'Get the recipient's email domain
           strAddress = objRecipient.Address
           strDomain = Right(strAddress, Len(strAddress) - InStr(strAddress, "@"))
 
           'If the domain is the specific one
           'Change the "datanumen.com" as per your needs
           If strDomain = "datanumen.com" Then
              'Convert the email format to plain text
              objMail.BodyFormat = olFormatPlain
              objMail.Save
              Exit For
           End If
      Next
    End If
End Sub

VBA Code - Send Plain Text Emails Only to Those in a Specific Domain

  1. After that, you have to sign this macro. Click the “Tools” > “Digital Signature” and follow onscreen wizard to complete it.
  2. Later, exit the current window. Then switch to “Developer” tab and tap on the “Macro Security” button. In the new popup dialog box, you should change the settings to enable digitally signed macros.
  3. Finally, you can take a shot. Create and compose an email to one recipient in a specific email domain. And hit “Send” button to send it out. In this process, Outlook will auto change the email format to Plain Text.

Restore Corrupt Outlook Files

Outlook is vulnerable to virus infection, malware attacks, power surge and so on. Thus we should learn some tips to restore Outlook data after corruption. At first, you should check your backups. If backup is too old or fail to be restored, you could utilize the built-in tool – Scanpst.exe. Of course, the inbox repair tool is not always effective. Thus, you had better prepare a reliable and cogent external tool, like DataNumen Outlook Repair. It is high recommended due to its high recovery rate.

Author Introduction:

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

Please follow and like us:
error

Enjoy this blog? Please spread the word :)

LinkedIn
Share
RSS