View Full Version : Emailing within Access - 'From' Field?


icezebra
03-14-2007, 02:58 AM
I have the following code:

Dim mess_body As String
Dim appOutLook
Dim Email As String
Dim MailOutLook

Email = MPTM

Set appOutLook = CreateObject("Outlook.Application")
Set MailOutLook = appOutLook.CreateItem(olMailItem)

mess_body = "Scheme: " + Scheme + vbCrLf
mess_body = mess_body + "Pin: " + Pin + vbCrLf + vbCrLf

Set appOutLook = CreateObject("Outlook.Application")
Set MailOutLook = appOutLook.CreateItem(olMailItem)
With MailOutLook
.To = Email
.Subject = "SUMIS Update"
.Body = mess_body
.DeleteAfterSubmit = True
.Send

End With

This sends an email through Outlook successfully. However I wondered if it's possible to set who the email is from?

I.e. under the line:
With MailOutLook
can I put something like:
.From = "BlahBlahBlah"
(I've tried this but it doesn't work)

Am I using the wrong instruction, or is it simply not possible?

Thanks!

MicroE
03-14-2007, 05:05 AM
Microsoft has established security within the mail client that prevents the From being changed programmatically.

icezebra
03-14-2007, 05:07 AM
Ah, I wondered if that was the case. Thanks for your help.

MicroE
03-14-2007, 05:19 AM
You are welcome.