Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Outlook from Field

Status
Not open for further replies.

JCG4LOM

Technical User
Jul 10, 2003
18
0
0
US
I have a third party vendor product that sends PDF files to clients. This product creates outlook emails to a drafts folder or just creates outlook emails and sends them. The product does not however have the ability to set the from field before sending the emails. I need a way to either have the emails as created or as sent assign a pre-defined from field email address. This will save me from opening each email and populating the from field before sending.
 
Ok, so I figured out most of this with some helpful code from the web. The following code works when I create draft emails. I select the draft or draft that I want to have a "From Field" populated for and run the macro. problem is at this point, I am getting the outlook is trying to send an email on your behalf message that needs to be worked out and I cannot get the macro to run when it is attached to an outlook button. Message: The Macro SendMail cannot be found.

Anyway, here is some code that may be useful to others with a similiar problem with populating the from field.

Sub SendMail()

Dim objApp As Outlook.Application
Dim objSelection As Outlook.Selection
Dim objExp As Outlook.Explorer
Dim objMsg As Object
'dim OlSecurityManager as Outlook.

Set objApp = New Outlook.Application
Set objExp = objApp.ActiveExplorer
Set objSelection = objExp.Selection

'OlSecurityManager.ConnectTo objOLApp
'OlSecurityManager.DisableOOMWarnings = True
'On Error GoTo Finally



For Each objMsg In objSelection
objMsg.SentOnBehalfOfName = "email@domain.com"
objMsg.Display
'objMsg.Send
Next

'Finally:
' OlSecurityManager.DisableOOMWarnings = False
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top