Outlook vba addin

Outlook vba addin DEFAULT
Request an Email Read Receipt

See how to request a read receipt based on the recipient of the message.

Outlook Add-In doesn´t start anymore

If an Addin doesn´t load anymore, it´s most likely due to entries in the Registry.

Add date at the cursor position

This macro is useful if you want to add a new note, for instance, to a contact or task.

GetSelectNamesDialog Pre-fill Search Box

Do you want to add some convenience for your users? See how to fill-in the search box of the address book by code.

Flag an Email for Follow-up

This demonstrates how to flag emails for follow-up.

Display the Email Address of the Recipient

Often the display name of an email recipient changes, making it impossible to sort these emails. This macro creates a new field with the pure email address.

VBA Editor: First Steps

See how to open the VBA environment of Microsoft Outlook, and how to add macros to ThisOutlookSession.

Resize Outlook Window

This free utility resizes the window of Outlook, so you're able to see or move it.

Quick-Cats

Assign categories to all your emails, appointments, contacts, etc. in the blink of an eye with the sidebar Quick-Cats. Even IMAP messages can be categorized.

Outlook Categories

See how to manage data in Outlook with categories or keywords. Use colors for groups of categories so that key issues strike you right away.

Sours: http://www.vboffice.net/

Which Outlook add-ins do I really need?

I checked the list of add-ins that I have installed for Outlook and I’m a bit surprised how many I have installed.

I thought I was just using “plain vanilla” Outlook without add-ins but apparently Outlook already comes with some pre-installed and some others were added by installing other applications.

I now try to “weed out” the additional add-ins hoping that it will improve my Outlook startup time as it is fast when launching Outlook in Safe Mode.

Which add-ins do I really need and which are safe to disable?

Button Add-insOutlook indeed already comes with its own set of add-ins. Not all of them are activated and not all the ones which are activated by default are needed in every configuration.

In addition, other Microsoft applications or 3rd party applications could add some add-ins to Outlook as well. Whether those are needed depends on if and how you use that application. In any case, they are not needed for proper operation of Outlook itself.

Then there are of course a whole lot of other add-ins which are primarily focused on adding functionality to Outlook. But as you’ve probably installed these type of add-ins more consciously, we’ll leave them out of this overview.

To see which add-ins you have installed and for instructions on how to disable them see: Enable/Disable add-ins.

Default add-ins from Outlook

The default add-ins that ship with Outlook are designed not to slow down Outlook in any way if you do not need them. Still, you are free to disable them if you don’t use them.

The default add-ins which are added depend on your version of Outlook and which additional applications from the Office Suite you have installed (so some might not be listed for you, which is OK). Below is an overview of these add-ins with an indication of when you really need it to have it enabled.

  • Business Connectivity Services AddIn
    Mainly used for integrating external SharePoint data in Outlook. If you are not connected to a SharePoint site, you do not need it. This add-in no longer exists in Outlook 2016 and later.
     
  • Microsoft Exchange Add-In
    Required for various Exchange account features. It is not needed when you do not have any Exchange accounts configured in Outlook.
     
  • Microsoft Outlook Social Connector / Outlook Social Connector 2013/2016
    This is the People Pane feature which shows at the bottom of the Reading Pane. It shows the recent interactivities you had with contacts of the selected message. It also used to allow you to connect to social media services such as Facebook, LinkedIn and Windows Live Messenger Contacts. It is not needed if you do not use this feature and Microsoft intends to remove this add-in with a future Microsoft 365 update.
     
  • Microsoft SharePoint Server Colleague Import Add-In
    This add-in scans your Sent Items folder to determine which colleagues are being offered on the Add Colleagues page on a user’s SharePoint My Site. It is not needed when you do not use SharePoint and even then, you are free to disable it if you do not like the feature.
     
  • Microsoft Teams Meeting Add-in for Microsoft Office
    When you have Microsoft Teams installed and then select the Calendar in Teams, this add-in is automatically added to Outlook. This add-in offers various integration features such as the “New Teams Meeting” button in the Calendar.
     
  • Skype Meeting add-in for Outlook 2016
    When you have Skype for Business installed (part of Microsoft 365 ProPlus), this add-in offers various integration features such as the “New Skype Meeting” button in the Calendar.
    Skype for Business is being replaced by Microsoft Teams so you may no longer have this add-in.
     
  • Microsoft Exchange Unified Messaging
    Required for when you use Outlook 2007 and have an Exchange mailbox which has Unified Messaging features enabled on the Exchange server.
     
  • OneNote Notes about Outlook Items
    In case you also use OneNote to save additional notes and have them linked with Outlook or create Task items in OneNote. For instance: Using OneNote to create linked Appointment Tasks.
    This add-in is not needed when you use the OneNote for Windows 10 app instead of OneNote as part of Microsoft 365 Apps or Office.
     
  • Microsoft Access Outlook Add-In for Data Collection and Publishing
    This add-in allows you to sync data with Access. Not needed if you do not use it and inactive by default.
     
  • Microsoft VBA for Outlook Add-in
    In case you want to use macros in Outlook, keep it enabled. It will only load when it is needed (which is why it is inactive by default).
     
  • Windows Search Email Indexer
    Leave this add-in disabled in Outlook 2010, Outlook 2013 and Outlook 2016 (MSI) as Outlook offers native indexing support. It has also been removed in later version of Office and Microsoft 365 Apps.

In Outlook 2007 and previous, you will also have the following Exchange Server client extensions which are only needed when you are using an Exchange account.

  • Delegate Access
  • Deleted Item Recovery
  • Exchange Extensions commands
  • Exchange Extensions property pages

Other common Microsoft add-ins you might encounter

There are various other Microsoft add-ins which may have been added to your list of Outlook add-ins. These all relate to other Microsoft applications or Outlook extensions which are installed on your system.

Their name usually reveals which application added them. If you do not use that application, it is safe to disable them.

Common third party add-ins you might encounter

Other applications may also add add-ins to Outlook which you might not have expected at first. For instance, iTunes adds the following 3 add-ins to Outlook:

  • iTunes Outlook AddIn
  • Outlook Change Notifier
  • iCloud Add-in

The first two are not needed if you do not sync your iPhone, iPad or iPod with Outlook via iTunes. The other add-in is not needed if you do not use iCloud in Outlook.

Virus scanner add-ins
There are also various virus scanners which add an add-in to Outlook. Disabling add-ins added by your virus scanner is actually recommended as they are a known source for causing strange send/receive problems and don’t add an additional layer of protection anyway. For further details on this see: Disable virus scanner integration?

Last modified: June 23, 2020

Sours: https://www.msoutlook.info/question/751
  1. Lm386 amplifier kit
  2. Minimalist stock photos
  3. Premid extension chrome
  4. Main st catskill ny

The Microsoft VBA for Outlook Addin is used to manage Microsoft Visual Basic application macros. Visual Basic projects are made up of modules that contain one or more macros also known as subroutines.


Click to see full answer.

Simply so, what is a COM add in outlook?

Using add-ins in Outlook.com. Add-ins in Outlook.com are programs or utilities that help you automate tasks when you view or create messages. Microsoft has partnered with leading companies to build add-ins that help you get things done right from your inbox.

Similarly, how do I permanently enable add ins in Outlook? Re-enable a disabled/inactive Outlook Add-in

  1. Go to File >Info.
  2. Select Manage COM Add-ins.
  3. In the windows, select Enable EasiShare Outlook Add-in, click on Always enable this add-in.
  4. Close Outlook and launch again. Note: If this does not work, try the last method below.

Also question is, what is the Outlook Change Notifier add in?

Actually there are two add-ins: “Outlook Change Notifier” and “iTunes Outlook Addin.” In typical Apple fashion, you didn't ask for them and the chances are you're not using them. The idea is that iTunes can be set up to sync contacts and calendar from Outlook.

How do I open VBA in Outlook?

Open the VBA EditorPress Alt+F11 on your keyboard, or if you are showing the Developer ribbon, click theVisual Basic Editor command to open it. In Outlook 2007 and older, the command in on the Tools, Macros menu.

Sours: https://everythingwhat.com/what-is-microsoft-vba-add-in-for-outlook
5 Productive Outlook Email Add-Ins

Customizing Outlook using COM add-ins

Creating a COM add-in involves two major steps:

  1. Implement the IDTExtensibility2 interface in a class module of a dynamic link library (DLL).
  2. Register the COM add-in.

Implement the IDTExtensibility2 Interface

The IDTExtensibility2 interface consists of five event procedures. To implement this interface in a Visual Basic program, set a reference to the Microsoft Add-In Designer object library and then add the following statement to the Declarations section of a class module:

You can then add the empty event procedures to the code window of the class module and add your own program code to the procedures. You can also copy the empty procedures from an Outlook COM Add-in Template.

Register the COM add-in

In order to work with Outlook, the add-in DLL must be registered. The DLL's class ID is registered beneath the \HKEY_CLASSES_ROOT subtree in the registry.

In addition, information about the add-in must be added to the registry. This information provides the add-in's name, description, target application, initial load behavior, and connection state.

Note If you use Microsoft Visual Basic 6.0 or later Developer to design your COM add-in, the add-in designer will perform the steps required to register the COM add-in for you.

The following example shows the contents of a sample registry-editor (.reg) file that illustrates how to register an Outlook COM add-in.

When the COM add-in is first registered, LoadBehavior can be set to any of the following flags.

ValueDescription
2Load at startup. The COM add-in is to be loaded and connected when Outlook starts.
8Load on demand. The COM add-in is to be loaded and connected only when the user requests it, such as by using the COM Add-ins dialog box.
16Connect first time. The COM add-in is loaded and connected the first time the user runs Outlook after the COM add-in has been registered. The next time Outlook is run, the COM add-in is loaded when the user requests it. Use this value if your COM add-in modifies the user interface to allow the user to request the COM add-in be connected on demand (by clicking a button, for example).

After the COM add-in is registered and loaded, the LoadBehavior value can be combined with either of the following two flags to indicate current connection state of the COM add-in.

FlagDescription
0Disconnected
1Connected

To connect the COM add-in, set the Connected flag in LoadBehavior; clear the flag to disconnect the COM add-in.

The FriendlyName value specifies the name of the COM add-in as it's displayed in the COM Add-in dialog box. The Description value provides additional information about the COM add-in.

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.

Sours: https://docs.microsoft.com/en-us/office/vba/outlook/concepts/getting-started/customizing-outlook-using-com-add-ins

Vba addin outlook

Outlook 2013 - What is the VBA Addin?

char...@email.com's profile photo

[email protected]

unread,
Nov 14, 2015, 11:04:09 PM11/14/15

Reply to author

Sign in to reply to author

Forward

Sign in to forward

Delete

Link

Report message as abuse

Sign in to report message as abuse

Show original message

Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message

to

In looking at the Addins in Outlook 2013, I see VBA - What is that Addin and
what is it used for? Is it necessary in running Outlook 2013?

Thanks for any insights!
charliec

char...@email.com's profile photo

[email protected]

unread,
Nov 15, 2015, 4:09:45 AM11/15/15

Reply to author

Sign in to reply to author

Forward

Sign in to forward

Delete

Link

Report message as abuse

Sign in to report message as abuse

Show original message

Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message

to

Thanks - should I uncheck it in Addins - I have a problem with Outlook starting
with a blank page the first time used after startup. All other Addins are
unchecked!
VanguardLH's profile photo

VanguardLH

unread,
Nov 15, 2015, 10:33:33 AM11/15/15

Reply to author

Sign in to reply to author

Forward

Sign in to forward

Delete

Link

Report message as abuse

Sign in to report message as abuse

Show original message

Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message

to

charliec wrote:

> Thanks - should I uncheck it in Addins - I have a problem with Outlook starting
> with a blank page the first time used after startup. All other Addins are
> unchecked!

You can disable some add-ins. Some you cannot disable (but may be able
to remove by re-running their installer to change the component config).
Under the Add-ins Manager in Outlook, click on the Go button. You'll
see which add-ins can be disabled (by unchecking them). VBA is not in
that list so you cannot disable it. Although listed as an add-in, it is
considered integral functionality within Outlook.

I just ran Change on MS Office 2013 Pro and there is an Add-in group for
Outlook but does not list the VBA add-in. It only lists the Sharepoint
and Outlook Social Connector. I don't have a Sharepoint server in my
home setup and I don't want a chat component in my Outlook so both of
those are marked Not Available. So it looks like you can neither
disable or uninstall the VBA add-in.

The VBA feature in Outlook is an interface to a a .dll file which has
the functions or methods that macros can call. Disabling add-ins does
not uninstall them, just remove them from the list and access by Outlook
or macros installed into Outlook. Unless Outlook pre-loads the DLL into
memory (to make fast access), a DLL won't consume any memory. I doubt
would see a smaller memory footprint if the non-disabled VBA function
were removed from Outlook.

Don't fret over the .dll file for VBA functionality within Outlook. It
is used by macros. So did you install any macros into Outlook? In
Outlook 2013, showing and managing macros is hidden by default. You
have to show the Developer tab in the ribbon: Options -> Customize,
enable the Developer tab group.
VanguardLH's profile photo

VanguardLH

unread,
Nov 15, 2015, 11:16:04 AM11/15/15

Reply to author

Sign in to reply to author

Forward

Sign in to forward

Delete

Link

Report message as abuse

Sign in to report message as abuse

Show original message

Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message

to

I took another look at Change for MS Office 2013 Pro. Under the
Microsoft Shared Features group, there is Visual Basic for Applications
that you can set to Not Available. Although I don't have any macros
installed into Outlook, I will leave VBA available in case I do need it
later. So you'll have to see if changing the installation config of
Ofice 2013 to uncheck VBA will remove it from Outlook.
VanguardLH's profile photo

VanguardLH

unread,
Nov 15, 2015, 11:33:51 AM11/15/15

Reply to author

Sign in to reply to author

Forward

Sign in to forward

Delete

Link

Report message as abuse

Sign in to report message as abuse

Show original message

Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message

to

VanguardLH wrote:

> I took another look at Change for MS Office 2013 Pro. Under the
> Microsoft Shared Features group, there is Visual Basic for Applications
> that you can set to Not Available. Although I don't have any macros
> installed into Outlook, I will leave VBA available in case I do need it
> later. So you'll have to see if changing the installation config of
> Ofice 2013 to uncheck VBA will remove it from Outlook.

I see when using Change that there is also a Visual Basic Script Support
option under Outlook. The above option is probably global in that VBA
support is removed from all modules of Office (Word, Excel, etc) verus
just VBA in Outlook. I don't see a VB option you can select/deslect for
Word, Excel, or Access so the global VBA option probably applies to all
Office modules. I don't know why Outlook's install config would
separately list a VB option.
char...@email.com's profile photo

[email protected]

unread,
Nov 15, 2015, 10:48:17 PM11/15/15

Reply to author

Sign in to reply to author

Forward

Sign in to forward

Delete

Link

Report message as abuse

Sign in to report message as abuse

Show original message

Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message

to

>On Sun, 15 Nov 2015 01:33:29 -0600, VanguardLH <[email protected]> wrote:

>charliec wrote:
>
>> Thanks - should I uncheck it in Addins - I have a problem with Outlook starting
>> with a blank page the first time used after startup. All other Addins are
>> unchecked!
>
>You can disable some add-ins. Some you cannot disable (but may be able
>to remove by re-running their installer to change the component config).
>Under the Add-ins Manager in Outlook, click on the Go button. You'll
>see which add-ins can be disabled (by unchecking them). VBA is not in
>that list so you cannot disable it. Although listed as an add-in, it is
>considered integral functionality within Outlook.
>
>I just ran Change on MS Office 2013 Pro and there is an Add-in group for
>Outlook but does not list the VBA add-in.

In Outlook/File/Options/Addins - under Com Add-Ins, it is listed as "Microsoft
VBA for Outlook Addin" and was checked. I unchecked it yesterday. Outlook
started correctly today at Startup, but the blank screen on Startup is not there
all the time. I need to wait a few days and see if it returns to that mode.


>It only lists the Sharepoint
>and Outlook Social Connector. I don't have a Sharepoint server in my
>home setup and I don't want a chat component in my Outlook so both of
>those are marked Not Available. So it looks like you can neither
>disable or uninstall the VBA add-in.
>
>The VBA feature in Outlook is an interface to a a .dll file which has
>the functions or methods that macros can call. Disabling add-ins does
>not uninstall them, just remove them from the list and access by Outlook
>or macros installed into Outlook. Unless Outlook pre-loads the DLL into
>memory (to make fast access), a DLL won't consume any memory. I doubt
>would see a smaller memory footprint if the non-disabled VBA function
>were removed from Outlook.
>
>Don't fret over the .dll file for VBA functionality within Outlook. It
>is used by macros. So did you install any macros into Outlook?

I have not installed any macros in Outlook.


>In
>Outlook 2013, showing and managing macros is hidden by default. You
>have to show the Developer tab in the ribbon: Options -> Customize,
>enable the Developer tab group.

Thanks
charliec
Sours: https://groups.google.com/
How to Add a New Task in Outlook using VBA - Outlook VBA Tutorial

VBA Code

COM Add-ins Using Default Security
In Microsoft all COM add-ins that run on a computer, not configured to obtain security settings from a Microsoft Exchange Server, are considered trusted by default. This implies that the add-ins that run on clients that are not Exchange clients and the add-ins that use default security in Exchange environments are trusted automatically.
The main Application object that is passed to the OnConnection event of the add-in. Read below for more information.
COM Add-ins Using Security Settings from an Exchange Server
There has been no change in the way Outlook trusts COM add-ins in an Exchange environment when the security settings are obtained from the Exchange server. An add-in will be considered trusted only if it's registered in the Security Settings folder. Again, as in Outlook 2002, Outlook 2003 trusts only the main Application object that is passed to the OnConnection event of the add-in.
Outlook Object Model Guard Improvements and its Impact on COM Add-ins
Outlook 2003 inherits the Outlook 2002 object model guard behavior, and in addition, blocks code that attempts to access the Body and HTMLBody properties of various Outlook items. This allows users to verify that the program or add-in accessing the Body and HTMLBody properties of items is trustworthy, before they allow access to the contents of the items. Even though this displays security warnings in the existing COM add-ins that access the Body or HTMLBody properties of items, this will help prevent malicious code from running without the user being aware of it.
You can avoid the display of security warnings by deriving all objects, properties, and methods from the Application object passed in the OnConnection procedure of the add-in. Outlook trusts only the Application object passed in the OnConnection procedure of the add-in. If you create a new Application object - for example, by using the CreateObject method - that object and any of its subordinate objects, properties, and methods will not be trusted and the blocked properties and methods will throw security warnings.


Sample Code for Writing a Trusted COM Add-in
The following add-in uses only the Application object (TrustedOL) passed in the OnConnection procedure of the add-in. Therefore, it does not display security warnings if run in an environment not running Exchange or in an Exchange environment where the add-in has been trusted by the administrator using the Security Settings folder.
This add-in adds a button to the Standard toolbar called "MailItem." When the user clicks the MailItem button, the add-in creates a mailitem and displays a message to the user without displaying any security warnings.
Copy Code

Dim TrustedOL As Outlook.Application
DimWithEvents oButton As Office.CommandBarButton

PrivateSub AddinInstance_OnConnection(ByVal Application As Object,
ByVal ConnectMode As AddInDesignerObjects.ext_ConnectMode, ByVal
AddInInst As Object, custom() AsVariant)
    Set TrustedOL = Application
    Set oButton = TrustedOL.ActiveExplorer.CommandBars.Item("Standard").Controls.Add(, , , 1, True)
    oButton.Caption = "MailItem"
EndSub

PrivateSub AddinInstance_OnDisconnection(ByVal RemoveMode As
AddInDesignerObjects.ext_DisconnectMode, custom() AsVariant)
    TrustedOL.ActiveExplorer.CommandBars.Item("Standard").Reset
    Set TrustedOL = Nothing
    Set oButton = Nothing
EndSub

PrivateSub obutton_Click(ByVal Ctrl As Office.CommandBarButton,
CancelDefault AsBoolean)
    Dim MI As Outlook.MailItem
    Dim oFolder As Outlook.MAPIFolder
    Dim MI2 As Outlook.MailItem
    
    Set MI = TrustedOL.CreateItem(olMailItem)
    MI.To = TrustedOL.Session.CurrentUser
    MI.Subject = "Test message from COM add-in"
    MI.Body = "This is the body."
    MI.Save
    
    Set oFolder = TrustedOL.Session.GetDefaultFolder(olFolderInbox)
    
    MsgBox ("I am going to move the item.")
    Set MI2 = MI.Move(oFolder)
    
        
    Set MI = Nothing
    Set oFolder = Nothing
    Set MI2 = Nothing
EndSub

Note For more information on writing trusted Outlook COM add-ins, see OL2002: How to Create Trusted Outlook COM Add-ins.
Known Issues
The following are known issues that result in an add-in hitting object model blocks even though it is constructed properly using the trust mechanism and is considered trusted by Outlook 2003.
Using the Inspector object in an Outlook form
When you attempt to bind a control to a property derived from the Inspector object, Outlook 2003 will show the security warning. A Microsoft Visual Basic for Applications (VBA) example is shown below with the line of code that shows the error highlighted in bold text. In this example, the control is being bound to a custom property, but Outlook will show a security warning if you try to bind a control to any property derived from the Inspector object.



PrivateSub obutton_Click(ByVal ctrl As Office.CommandBarButton,
CancelDefault AsBoolean)
    Dim mai As Outlook.MailItem
    Dim uprs As Outlook.UserProperties
    Dim upr As Outlook.UserProperty
    Dim isp As Outlook.Inspector
    Dim pags As Pages
    Dim pag As MSForms.UserForm
    Dim ctrl1 As MSForms.Control
    Dim ctrls As MSForms.Controls
    
    Set mai = outApp.CreateItem(olMailItem)
    mai.To = outApp.Session.CurrentUser
    mai.Save
    mai.Subject = "Yes/No binding to a Controls"
    Set uprs = mai.UserProperties
    Set isp = mai.GetInspector
    
    Set pags = isp.ModifiedFormPages
    Set pag = pags.Add("MyFirstPage")
    Debug.Print pags.Count
    Set upr = uprs.Add("MyFormula", olFormula)
    upr.Formula = "[To]"
    Set ctrls = pag.Controls
    Set ctrl1 = ctrls.Add("Forms.TextBox.1", "MyText", 1)
    ctrl1.ItemProperty = "MyFormula"
    ctrl1.ControlProperty = "Value"
    isp.ShowFormPage "MyFirstPage"
    mai.Display
    
EndSub

A workaround for this scenario is to use the SetControlItemProperty method of the Inspector object, replacing the line that causes the security warning:


ctrl1.ItemProperty = "MyFormula"
With this line:


isp.SetControlItemProperty(ctrl1, "MyFormula")
New Object Model Blocks in Outlook 2003
The following are the additional properties that have been blocked in Outlook 2003:


The IMAddress and Body properties of a ContactItem object.
The HTMLBody and Body properties of a MailItem object.
The HTMLBody and Body properties of a PostItem object.
The Body property of an AppointmentItem object.
The Body property of a TaskItem object.
The Body property of a TaskRequestItem object.
The Body property of a TaskRequestAcceptItem object.
The Body property of a TaskRequestDeclineItem object.
The Body property of a TaskRequestUpdateItem object.
The Body property of a DistListItem object.
The Body property of a JournalItem object.
The Body property of a MeetingItem object.
The Body property of a ReportItem object.
The Body property of a RemoteItem object.
The Body property of a NoteItem object.
The Body property of a DocumentItem object.
Also, if you use a third-party add-ins, custom solutions, or other programs that integrates with Outlook 2003, you may receive one or more of the following warnings:


A program is trying to automatically send e-mail on your behalf. Do you want to allow this? If you unexpectedly receive this message, it may be caused by a virus, and you should choose No.
A program is trying to access e-mail addresses you have stored in Outlook. Do you want to allow this? If you unexpectedly receive this message, it may be caused by a virus, and you should choose No.
These warning messages are commonly associated with software that is designed to synchronize Outlook data with handheld computers, but may occur with any type of add-in or custom solution.
Note For more information about the Outlook 2002 Object Model Guard, see Microsoft Outlook 2002 Developer Security Overview.
Why a Change in Trust Model in Outlook 2003 and Not in Previous Versions of Outlook?
There are two major factors that contributed to this change in trust model in Outlook 2003. The first is that Outlook 2003 is the first version of Outlook that has Microsoft Windows 2000 SP3 as its minimum platform version. Previous versions of Outlook supported Microsoft Windows 98 operating systems. The second reason is that with the additional object model blocks that are added in Outlook 2003, there are tasks that independent software vendors (ISV) need to handle, that do not have any simple workarounds.



© 2021 Better Solutions Limited. All Rights Reserved. © 2021 Better Solutions LimitedTopPrev
Sours: https://bettersolutions.com/outlook/add-ins/vba-code.htm

You will also be interested:

Converting an Outlook Macro to a VSTO Addin

Last Updated on Mon, 30 Aug 2021 | Visual Studio 2005 VBA

In this section you will create a simple VBA macro for Outlook and convert the code to a VSTO add-in. The VBA code is in the ItemSend event handler of the Application object in a VBA project, as shown in Listing 10.1.

Listing 10.1. VBA macro that checks for a subject on an outgoing e-mail

Private Sub Application_ItemSend(ByVal Item As Object, _ Cancel As Boolean)

Dim sendMessage As Integer

If Item.Class = olMail Then If Item.Subject = "" Then sendMessage = MsgBox("Subject text is missing." & _ vbCrLf & vbCrLf & "Do you want to send this" & _ " message?", vbYesNo, "Missing Subject")

If sendMessage = vbNo Then Cancel = True Item.Display End If End If End If End Sub

To convert this to a VSTO add-in, you'll first create an add-in project, as described earlier in this chapter.

1. Create an Outlook add-in project with VSTO.

2. Right-click ThisApplication in Solution Explorer, and click View Code.

3. In the Class Name drop-down, select (ThisApplication Events), and then select ItemSend in the MethodName drop-down, as shown in Figure 10.6.

Figure 10.6. ItemSend event handler

4. Add the code in Listing 10.2 to the ItemSend event handler. Note that the only change necessary to the code is displayed in bold font.

Listing 10.2. VSTO add-in that checks for a subject on an outgoing e-mail

Private Sub ThisApplication_ItemSend(ByVal Item As Object, _ ByRef Cancel As Boolean) Handles Me.ItemSend

Dim sendMessage As Integer

If Item.Class = Outlook.OlObjectClass.olMail Then If Item.Subject = "" Then sendMessage = MsgBox("Subject text is missing." & _ vbCrLf & vbCrLf & "Do you want to send " _ & "this message?", vbYesNo, "Missing Subject") If sendMessage = vbNo Then Cancel = True Item.Display() End If End If End If End Sub

5. Press F5 to run the code.

6. Create an e-mail without filling in the Subject text box, and then click Send. The message box (indicating that there's no Subject text) should appear and give you the opportunity to add the text or send the message as is.

You can also make further modifications to the code to use some of the features of Visual Basic 2005, as shown in Listing 10.3.

Listing 10.3. Further modifying the VSTO add-in code

Private Sub ThisApplication_ItemSend(ByVal Item As Object, _ ByRef Cancel As Boolean) Handles Me.ItemSend

Dim myMailItem As Outlook.MailItem = _ TryCast(Item, Outlook.MailItem)

If myMailItem IsNot Nothing AndAlso myMailItem.Subject = _ String.Empty Then

If MsgBox("Subject text is missing." & vbCrLf & _ vbCrLf & "Do you want to send this message?", _ MsgBoxStyle.YesNo, "Missing Subject") = _ MsgBoxResult.No Then

Cancel = True myMailItem.Display()

End If End If End Sub

Here, we cast the Item (which is of type Object) to a MailItem. We used TryCast because if the attempt to cast the object fails, TryCast returns Nothing instead of an InvalidCastException error that we'd have to handle. With TryCast you can test to be sure that the object is not Nothing before performing additional operations on it.

The code also uses AndAlso to first check whether myMailItem is Nothing and, if it isn't, whether the Subject property is empty; only then does it execute the remainder of the code. Instead of using nested If statements or using the And operator (which would always check both conditions), we use AndAlso, which checks the second condition only if the first condition is True, thus preventing the exception that would otherwise occur. Finally, the code checks the DialogResult of the message box directly. In this way, we don't need to create a separate variable for an integer that represents the VBA constants vbNo and vbYes.

Continue reading here: Creating a Simple Addin

Was this article helpful?

Sours: https://www.engram9.info/visual-studio-2005-vba/converting-an-outlook-macro-to-a-vsto-addin.html


1652 1653 1654 1655 1656