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

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
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,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

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