Outlook button copy "from" addresses to clipboard...

I need a macro or vb script that would allow me to select a bunch of emails in outlook and
right click and have all the "from" addresses copied to the clipboard seperated by a LF
or
after selecting the emails, a button on the tool bar that would add addresses to clip seperated by a LF.

It would also be nice to have the clipboard saved as date-address.txt some where,
but thats allot for the points chosen.

If someone can do both, I will add value to the points awarded ;)

btw,
I will add the button by the directions at http://www.outlookcode.com/d/code/formontoolbar.htm

GHBoom
ghboomAsked:
Who is Participating?
 
David LeeCommented:
ghboom,

Here's the code for doing this.  Follow these instructions to use it.

1.  Start Outlook
2.  Click Tools->Macro->Visual Basic Editor
3.  If not already expanded, expand Modules and click on Module1
4.  Copy the code below and paste it into the right-hand pane of the VB Editor
5.  Edit the code as needed.  I put a comment immediately before where something needs to change
6.  Click Tools->References.
7.  If not already checked, place a checkmark next to "Microsoft Forms 2.0 Object Library".
8.  Click the diskette icon on the toolbar to save the changes
9.  Close the VB Editor
10.  Click Tools->Macro->Security
11.  Change the Security Level setting to Medium
12.  Select the messages you want to save the from address of and run the macro.  It will save them all directly to a text file and to the clipboard at the same time.

'Macro Begins Here
Sub SaveFromAddresses()
    Dim olkMessage As Outlook.MailItem, _
        objFSO As Object, _
        objFile As Object, _
        objData As New DataObject, _
        strAddresses
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    'Change the path on the following line as needed.
    Set objFile = objFSO.CreateTextFile("C:\eeTesting\" & Year(Date) & StrZero(Month(Date), 2) & StrZero(Day(Date), 2) & ".txt")
    For Each olkMessage In Application.ActiveExplorer.Selection
        objFile.WriteLine olkMessage.SenderEmailAddress
        strAddresses = strAddresses & olkMessage.SenderEmailAddress & vbCrLf
    Next
    objData.SetText strAddresses
    objData.PutInClipboard
    Set objData = Nothing
    Set olkMessage = Nothing
    objFile.Close
    Set objFile = Nothing
    Set objFSO = Nothing
End Sub

Function StrZero(varNumber As Variant, intLength As Integer) As String
    Dim intItemLength As Integer, _
        intDifference As Integer
    If IsNumeric(varNumber) Then
        intItemLength = Len(CStr(Int(varNumber)))
        If intItemLength < intLength Then
            intDifference = intLength - intItemLength
            StrZero = String(intDifference, "0") & varNumber
        Else
            StrZero = varNumber
        End If
    Else
        StrZero = varNumber
    End If
End Function
'Macro Ends Here
0
 
David LeeCommented:
Greetings, ghboom.

I can produce the macro.  There's a hitch though that you need to be aware of.  Accessing an address field, any address field, in Outlook is going to trigger its built-in security which will pop up a dialog-box warning that a program is accessing your mailbox and asking for permission to allow it to continue.  If that's not a problem, then I'll get the code posted.

Cheers!
0
 
p912sCommented:
To handle the security warning you can use a little utility called ClickYes.

http://www.contextmagic.com/express-clickyes/
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
ghboomAuthor Commented:
BlueDevilFan,

By all means its a small price to pay for the convienance !!!

GHBoom
0
 
ghboomAuthor Commented:
I have not had time to test your solution, but you deserve the points ;)

I did not want the question PAQed !

In a day or so I will test and let you know how I made out ;)

Thanks !!!
GHBoom
0
 
ghboomAuthor Commented:
Well I fgured Im up I might as well...

I dont have "Microsoft Forms 2.0 Object Library". listed in available refrences ?
Im using outlook 2002 sp2 on xp sp2 ...

GHBoom

 
0
 
David LeeCommented:
Look in C:\Windows\System32 for a file named FM20.dll  If it's there, then run this command

    regsvr32 c:\windows\fm20.dll

and see if it appears now.  
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.