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
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 ;)

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

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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.

To handle the security warning you can use a little utility called ClickYes.

ghboomAuthor Commented:

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

Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

David LeeCommented:

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, _
    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
    objData.SetText strAddresses
    Set objData = Nothing
    Set olkMessage = Nothing
    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
            StrZero = varNumber
        End If
        StrZero = varNumber
    End If
End Function
'Macro Ends Here

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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 !!!
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 ...


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.  
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.