vba to check which Email Account is in use (1 Viewer)

GaryPanic

Smoke me a Kipper,Skipper
Local time
Today, 13:39
Joined
Nov 8, 2005
Messages
3,294
Hi Guys - this is a continuation but seperate from a previous post

My users have two accounts and I have email automation to copy rename and file emails (working like a charm-code pinched from somewhere)
The issue is that it worksw on default email account - - OK so temporary I have it looking at "named" email Accounts linked to a form which states which acc to use

its a temp fix while I try to resolve the following
I deally what i want is the code (or form) to look at the email account being used .

Example a form may have "Dave" on it but it is being serviced by Jane

my code at the moment look at "Dave" email accounts as these are on the form - what I need is for the code(form) to look at the email account being used - so jane




what it needs to do is look at
 

GaryPanic

Smoke me a Kipper,Skipper
Local time
Today, 13:39
Joined
Nov 8, 2005
Messages
3,294
Is the current users email (there maybe two ) and I can then get the code to check that sent folder

(sorry for the split note - interent is being wobbly again.. my original problem was called "Minor Meltdown" )
 

Isaac

Lifelong Learner
Local time
Today, 13:39
Joined
Mar 14, 2017
Messages
8,777
As I questioned in the last post when you asked the same question. Instead of approaching this as "how do I determine which Outlook account is in use?", why not approach this as "how do I determine who is the logged-in user on the machine using my Access database?" - since the latter is much more commonly done, and there is broad support, advice & precedent for how to do it.

From there, you may be able to construct an email address.

An alternative:

Get the email address of the current user from their local Outlook with one line of code:

?CreateObject("Outlook.Application").session.currentuser.addressentry.getexchangeuser().primarysmtpaddress
 

GaryPanic

Smoke me a Kipper,Skipper
Local time
Today, 13:39
Joined
Nov 8, 2005
Messages
3,294
thanks for your response

knowing who is logged in only answer half the question as I would still need to know what Outlook profile they are using

on occasions I would have Gary using an EU email address and on occasions Gary using an non eu email address I could also have Gary using a third account (rare but "possible")-

I will try the code above - but it looks like it could only return the primary ? will advised

and your response is appricated (I bet the solution is going to be really easy ..)

keep safe.
 

Isaac

Lifelong Learner
Local time
Today, 13:39
Joined
Mar 14, 2017
Messages
8,777
I would still need to know what Outlook profile they are using
by Profile, do you truly mean an actual Windows Mail Profile? The thing that, IF you set up a "second" one (in addition to the Default), then Outlook (when opened), will Prompt you for which profile to use?

in that case, even my code unfortunately, will actually prompt for that profile when opening outlook.

instead, if you just are referring to the fact that people can have numerous Outlook accounts/addresses added to their outlook, then i'm not sure how you would decide which one you want to look at? I haven't heard anything yet that defines that.

if Gary's outlook has 6 accounts added to it, corresponding to 6 different potential "from" addresses - gary@outlook.com, gary@something.eu, gary@something.uk, etc........then how do YOU know which account you want the email address from?

confused...

in other words, how do YOU define "using" ? if a person has 6 email accounts added to their Outlook, then they are using all 6 of them.

personally, when i had cases where i wrote Access/Excel apps to manipulate people's Outlook and I wanted to make use of shared mailboxes specifically, i trained my users to actually create a separate Mail profile on their machine, containing ONLY the shared mailbox - and open that mail profile prior to running my vba. kept it simple..
 

Users who are viewing this thread

Top Bottom