Outlook VBA code crashes Outlook! - Techist - Tech Forum

Go Back   Techist - Tech Forum > Computer Software > Microsoft Windows and Software
Closed Thread
Thread Tools Display Modes
Old 04-19-2005, 08:00 PM   #1 (permalink)
Newb Techie
Join Date: Apr 2005
Posts: 2
Default Outlook VBA code crashes Outlook!

I know that it is bad form to post a question first post, but I am tearing my hair out over this...

I wrote a small VBA script to strip sender addresses from emails and put them into a .TXT file on the desktop. It runs OK on my Outlook 2003, but when run on my bosses machine, we get the following error:

"Outlook experienced a serious error the last time the add-in..." thats all i got before the window was closed. The add-in mentioned was a VBA add-in.

Here is the code:
Sub GetUnsubAddresses()
Dim myOlApp As Outlook.Application
Dim mpfBox As Outlook.MAPIFolder
Dim obj As Outlook.MailItem
Dim i As Integer
Dim myFileName
Set myOlApp = CreateObject("Outlook.Application")
Set mpfBox = myOlApp.GetNamespace("MAPI").GetDefaultFolder(olFo lderInbox).Folders("mailboxAtZoomdirect")

'create text file to write unsubs to
Set ObjFSO = CreateObject("Scripting.FileSystemObject")
Set ObjFile = ObjFSO.CreateTextFile("C:\Documents and Settings\chris.TEMPEST\Desktop\unsubs.txt")
' Loop all items in the Inbox\Test Folder
For i = 1 To mpfBox.Items.Count
If mpfBox.Items(i).Class = olMail Then
Set obj = mpfBox.Items.Item(i)

'write the unsubs to text file
ObjFile.WriteLine obj.SenderEmailAddress
End If

'close text file object
Set ObjFile = Nothing
Set ObjFSO = Nothing

End Sub
Any ideas on WHY this is happening would be greatly appeciated. Im at my wits end!! Thank you in advance, Chris.

the_goldfish is offline  
Old 04-19-2005, 09:25 PM   #2 (permalink)
Ultra Techie
Join Date: Apr 2005
Posts: 720

He running diff ver?

SkyHi is offline  
Old 04-19-2005, 09:44 PM   #3 (permalink)
Newb Techie
Join Date: Apr 2005
Posts: 2

Nope, he is on the saem version of office and Outlook as me...2003.
the_goldfish is offline  
Old 04-21-2005, 08:21 AM   #4 (permalink)
True Techie
Join Date: Apr 2005
Posts: 148

go to www.vbcity.com and post your question there. They have an excellent website for anything vb related. VB6, .NET, C#, etc...

GrayWolf is offline  
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Our Communities

Our communities encompass many different hobbies and interests, but each one is built on friendly, intelligent membership.

» More about our Communities

Automotive Communities

Our Automotive communities encompass many different makes and models. From U.S. domestics to European Saloons.

» More about our Automotive Communities

Marine Communities

Our Marine websites focus on Cruising and Sailing Vessels, including forums and the largest cruising Wiki project on the web today.

» More about our Marine Communities

Copyright 2002-2015 Social Knowledge, LLC All Rights Reserved.

All times are GMT -5. The time now is 07:02 PM.

Powered by vBulletin® Version 3.8.8 Beta 1
Copyright ©2000 - 2016, vBulletin Solutions, Inc.