Retrieve the Users Email address

GRCArizona

Board Regular
Joined
Apr 24, 2010
Messages
95
Hi - I've got a work file that is on our company's network. I'm trying to put in a layer of security to ensure that when someone opens up the file, a macro will run and check the Users email address (in our Outlook) to make sure the email address has our company's extension (IE: user@honeywell.com). If the extension is Honeywell, then the file can proceed, if not then it shuts down / closes / etc.

Hope I explained that correctly.

the only code I can come across is to determine UserName.

Anyone have any suggestions?

Thanks,
grc
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
the only code I can come across is to determine UserName.

But the user who runs the macro, already logged in.
Why would you add a second layer of security - in addition, one that is superfluous since the authentication already took place.
 
Upvote 0
I could come up with a way to do it, it works in my tests:

Code:
Sub fff()
    
    Dim bFound As Boolean
    bFound = False
    For Each objAccount In Outlook.Application.Session.Accounts
         If InStr(objAccount.SmtpAddress, "@honeywell.com") Then bFound = True: Exit For
    Next
    
    If bFound Then
        
        'your code
        
    End If

End Sub
 
Upvote 0

Forum statistics

Threads
1,214,661
Messages
6,120,796
Members
448,994
Latest member
rohitsomani

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top