Outlook Email

teel73

Registered User.
Local time
Today, 03:44
Joined
Jun 26, 2007
Messages
205
I have some code that automatically sends a HTML formatted email from Access. What I would like to additionally accomplish is changing the "FROM" column programatically. The email should be coming from a group mailbox but whoever is clicking the button, will be captured as the sender. Is there a way I can program that using VBA? Here is what I have below that works fine except the email comes from me. Thanks in advance for any help.


Code:
Dim olApplication As Outlook.Application
Dim olns As Outlook.NameSpace
Dim myItem As Outlook.MailItem
 
Set olApplication = CreateObject("Outlook.Application")
Set olns = olApplication.GetNamespace("MAPI")
Set myItem = olApplication.CreateItem(olMailItem)

myItem.HTMLBody = "<HTML><BODY><P>Fannie Mae Hiring Manager/ Point of Contact:</P>"
 
myItem.Subject = theSub
myItem.Display
myItem.To = "" & theVendor
myItem.cc = "" & theCC
 
I attempted to do that last year and I recall Outlook giving me an error as it tried to prevent me from impersonating someone else. Must be possible since the spammers have no problem doing it but they are probably not using Outlook. ;-)
 
Take a look at
myitem.SendUsingAccount to send from the group account
 
Thanks for the quick response. This is a group mailbox that I have access to. I can manually change the "From" to send from this group mailbox. I just figured I should be able to do it using VBA as well.

How do you use the SendUsingAccount? is SendUsingAccount a method or property? I put the following code and it didn't put the address in the From box:

Code:
myItem.SendUsingAccount = "[EMAIL="corporate_security@fanniemae.com"]corporate_security@fanniemae.com[/EMAIL]"
 

Users who are viewing this thread

Back
Top Bottom