How to log into a specific outlook user account via vba in access

aliT

Registered User.
Local time
Today, 07:46
Joined
Jul 31, 2013
Messages
10
Anyone know how to log into a specific outlook user account and then send an email from that account please? I need the code

At the moment i can only get it to send emails from the account my outlook logs into by default ie my own profile's account.

thanks

ali
 
Hello aliT, I am not sure about logging in using VBA.. but if you have added the account you wish to use to your Outlook Accounts.. Then you can choose which account you wish emails to be sent out from.. Is that something you might be interested in doing?
 
Yes please, how can i add the accounts and how can i use them please

thankyou
 
How do i manually add the accounts. Do i need to enter the other users passwords?
 
Thanks very much for that. you are a star
 
Glad to help.. Post back if you are stuck.. :)
 
I have a problem in that the logon method doesnt seem to work. It still sends from my own profile. And when i put a random password it doesnt give an error and continues to send from my own account. Any ideas?

Dim sPwd As String, sUserName As String
Dim olApp As Outlook.Application
Dim oNS As Outlook.NameSpace
Set olApp = GetObject(, "Outlook.Application")
Set oNS = olApp.GetNamespace("MAPI")
sUserName = InputBox("Please enter username")
sPwd = InputBox("Please enter your login password.")
oNS.Logon sUserName, sPwd, False, True
Dim oMsg As Outlook.MailItem
Set oMsg = oNS.Session.Application.CreateItem(olMailItem)
oMsg.To etc
oMsg.Send 'always sends from my currently logged in account on the pc
 
Sorry if I was not clear.. You need to Manually set up the email account.. The code I had given you assumes the account is already linked to you Outlook..

The code you have presented does not use the code I gave you..
 
Aha, sorry, but as far as you know is it possible to do it without adding an account, by using the logon method as above ie
oNS.Logon sUserName, sPwd, False, True
 
It might be possible, but the code I gave would most definitely not do that.. You can play around with that.. I will (not assuring but) try to play around and see if it is possible..
 

Users who are viewing this thread

Back
Top Bottom