Do you often use the attachment name as the email subject in Outlook? If so, you must hope that Outlook can automatically complete it. This article will introduce a handy method to make it realized with Outlook VBA.
Many users are accustomed to manually typing the attachment name in the email subject line. In such a scenario, if Outlook can auto accomplish it, it’ll be far more convenient. Also, some users often forget to fill the subject line. So, when hitting “Send” button, they will receive a “no subject” warning message. In such a case, if Outlook can automatically fill the subject with the attachment name, they will be able to avoid the annoying “no subject” warning. In a nutshell, it is believed that a lot of Outlook users are longing for such a method to let Outlook auto fill the mail subject line with the attachment name. Fortunately, with the help of Outlook VBA, we can achieve it with utmost ease. Here are the elaborate VBA codes and steps.
Auto Fill Email Subject Line with the Attachment Name
- In the first place, you can start Outlook and switch to “Developer” tab.
- Then under this tab, you should click on the “Visual Basic’ button, which will bring out the VBA editor.
- In the subsequent window, you ought to first locate the “ThisOutlookSession” project in the project list on the right side.
- Next double click to open this project. And then copy the following codes into it.
Public WithEvents olInspectors As Outlook.Inspectors Public WithEvents olMail As Outlook.MailItem Private Sub Initialize_handlers() Set olInspectors = Application.Inspectors End Sub Private Sub olInspectors_NewInspector(ByVal Inspector As Inspector) Dim olItem As Object Set olItem = Inspector.CurrentItem If TypeName(olItem) = "MailItem" Then Set olMail = olItem End Sub Private Sub olMail_AttachmentAdd(ByVal Attachment As Attachment) If olMail.Subject = "" Then 'If you don't want the prompt, 'Just delete the Msgbox line and its corresponding "End if". If MsgBox("Do you want to use the attachment name as the subject", vbYesNo) = vbYes Then olMail.Subject = Attachment.DisplayName End If End If End Sub
- After that, you need continue to assign a digital certificate to the current VBA project as normal.
- Firstly, utilize the inbuilt utility “Digital Certificates for VBA Projects” to generate a digital certificate.
- Subsequently, you can sign the current macro.
- Later exit the VBA editor and change the macro settings to “Notifications for digitally signed macros, all other macros disabled”.
- Finally you can have a try.
- Create a new email.
- If you haven’t filled the subject and intend to attach a file, you will receive a message, like the following image:
- When you select “Yes”, subject will be filled with the attachment name at once.
Cope with Frequent Outlook Issues
Provided that you’ve used Outlook for decades, you must have encountered a lot of Outlook problems. Then, what actions do you usually take when meeting them? It is suggested to figure out and eradicate them as soon as possible. It is because that accumulating issues can damage your Outlook data at any time. Hence, even if Outlook can work as normal, you had better apply either the inbox repair tool or the external Outlook PST error repair utility, like DataNumen Outlook Repair, to scan your PST files to detect and solve errors.
Author Introduction:
Shirley Zhang is a data recovery expert in DataNumen, Inc., which is the world leader in data recovery technologies, including repair damaged SQL Server database and outlook repair software products. For more information visit www.datanumen.com
Leave a Reply