MS Access send email (not from outlook or user’s email)

calendar_today Asked Jul 20, 2012
thumb_up 11 upvotes
history Updated April 16, 2026

Question posted 2012 · +7 upvotes

I know this question has been asked a few times in various context, but I have not found a clear answer. I have email implemented for an access application using outlook, but I’d like to move away from this. One of the purposes of the email is to email a user his/or password if he forgot it. They can select their username for the login screen, and if they click ‘forgot password’ and email is sent containing their login information (to the email address associated with the user name).

The problem with this is that the email function as is sends an email with outlook from the user’s machine. So, users would be able to ‘forgot password’ other usernames and view their own outlook outbox(sent items) to see the sensitive information.

Is there a way to e-mail like php’s mail function, sending mail from the server? I would like the emails to be sent from the same email address i.e([email protected]), instead of from the user’s outlook address after a security prompt. If this is not possible, I am open to the idea of any other workarounds.

I will also add that installing any software that would have to be installed on every potential user’s machine is not feasible.

Is this possible?

Accepted answer +11 upvotes

This works for me in MS Access 2010 / Windows 7

sMailServer = "myISPsmtp" 'Not just any old smtp
sMailFromAddress = "me"
sMailToAddress = "me"

Set ObjMessage = CreateObject("CDO.Message")
sToAddress = sMailToAddress
sSubject = "Subject"
sBody = "MailBody"

ObjMessage.Subject = sSubject
ObjMessage.From = sMailFromAddress
ObjMessage.To = sToAddress
'ObjMessage.cc = sCCAddress
ObjMessage.TextBody = sBody
'ObjMessage.AddAttachment sMailAttachment
ObjMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
ObjMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = sMailServer
ObjMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
ObjMessage.Configuration.Fields.Update
ObjMessage.send

More info: http://msdn.microsoft.com/en-us/library/ms526318(v=exchg.10).aspx

VBA Core objects referenced (5)

  • CDO.Message — Automatically Dismiss a Message Box
  • CDO.Message — Display Address Entry Details for the Sender of a Message
  • Fields.Item — Allow users to add items to an unbound combo box
  • Fields.Item — Create a Sendable Item for a Specific Account Based on the Current Folder (Outlook)
  • ObjMessage.From — Controlling One Microsoft Office Application from Another

Top vba Q&A (6)

+11 upvotes ranks this answer #36 out of 81 vba solutions on this site .
vba