How do I combine these macros so they load with Outlook startup?
Posted on 2008-10-30
I would like to know how I can combine these two macros so that they open automatically on Outlook startup (providing the user clicks enable - The security is set to ask). And I would like it so that the second part of this macro doesn't run again if it has already changed the registry info that it was supposed to the first time it is ran.
Here is the code I'm talking about:
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
Dim olkRecipient As Outlook.Recipient, _
olkNewRecipient As Outlook.Recipient, _
strAddress As String, _
intIndex As Integer
If Item.Class = olMail Then
For intIndex = Item.Recipients.Count To 1 Step -1
Set olkRecipient = Item.Recipients(intIndex)
If InStr(1, olkRecipient.Address, "@") Then
If Not (InStr(1, LCase(olkRecipient.Address), ".mlxjet.com") > 0) Then
strAddress = olkRecipient.Address & ".mlxjet.com"
Set olkNewRecipient = Item.Recipients.Add(strAddress)
olkNewRecipient.Type = olBCC
olkNewRecipient.Type = olkRecipient.Type
Macro 2 (I would like this part to be added to macro 1 so that it runs once, if what it does has not been done yet):
Dim objShell As Object, arrVersionInfo As Variant
arrVersionInfo = Split(Application.Version, ".")
Set objShell = CreateObject("Wscript.Shell")
objShell.RegWrite "HKCU\Software\Microsoft\Office\" & arrVersionInfo(0) & ".0\Outlook\Options\Mail\BlockExtContent", 0, "REG_DWORD"
Set objShell = Nothing