[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 260
  • Last Modified:

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
0
ghboom
Asked:
ghboom
  • 3
  • 3
1 Solution
 
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
 
ghboomAuthor Commented:
BlueDevilFan,

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

GHBoom
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

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

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now