Sending emails

kadara

Registered User.
Local time
Today, 03:19
Joined
Jun 19, 2010
Messages
43
Hi,

I created a module to send emails with Outlook. I would like to save some informations to a table. These infos are: the name (or email address) of the recipients (the sender, To, CC, BCC). I successfully solved to save the To CC BCC recipients, but I couldn't get the informations about the sender. This database it used by more users, and I would like to save the name or email address of that person wich send the email (for example I send an email to several persons and I would like to save to a table the name or address of each person including me).
Any kind of help is appreciated.
Thanks
 
I am assuming you have the code to create your email already and you are using some code to fill the table, so all you might need is the Environ("UserName") to be added to your table.

Are you interacting with a form to do this?

If I am miss reading your thread, please copy your code into your reply.
 
If your Database is secured with User Groups/Users etc. you can use the CurrentUser Function to read the current User Name and save it in a Table along with current date etc.

If the database is not implemented with MS-Access Security then you can get the User who has Logged into Windows for current session, with the Function ENVIRON("UserName"). That you can save it in a table through your Email VBA Code while sending mail.

Sample Code:

Code:
Dim db as Database, rst as Recordset

set db = Currentdb
set rst = db.OpenRecordSet("MailSend",dbOpenDynaset)
rst.Add
rst![UserName] = CurrentUser

'OR
'rst![UserName] = ENVIRON("UserName")

rst![MailDate] = Now()
rst.Update
rst.Close

Set rst = Nothing
Set db = Nothing

Take a look at this link for clues for automating Emails on fixed intervals: Automated E-mail Alerts
 
Thanks.
The ENVIRON("UserName") working fine.
But is there any possibility to get the email addres of the current user and save it to the table?
Note to Environ method: at my worplace the username is set as follow: LastName FirstName and also we get an Alias (for example: John Smith and the alias is "smithj"). The ENVIRON("UserName") return the alias (smithj) for ther username. Is there a possibility to return the full name (LastName FirstName) and the email address (the email address format is lastname.firstname@companyname.com)?
Thanks.
 

Users who are viewing this thread

Back
Top Bottom