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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Send Outlook mail as delegate? 1

Status
Not open for further replies.

padinka

Programmer
Jul 17, 2000
128
US
I need to be able to send outlook mail as the delegate of someone else via code. (I have permission in outlook and can do this manually) How would I modifiy the sample code below to allow me to send From: someone else?

Sub SendMessage(DisplayMsg As Boolean, Optional AttachmentPath)
Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim objOutlookAttach As Outlook.Attachment
Dim dfdMail As Outlook.MAPIFolder


' Create the Outlook session.
Set objOutlook = CreateObject("Outlook.Application")

' Create the message.
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)

With objOutlookMsg
' Add the To recipient(s) to the message.
Set objOutlookRecip = .Recipients.Add("rfw2147403_MAPS_NETBK")
objOutlookRecip.Type = olTo



' Add the BCC recipient(s) to the message.
Set objOutlookRecip = .Recipients.Add("Greenlea, Patricia")
objOutlookRecip.Type = olBCC

' Set the Subject, Body, and Importance of the message.
.Subject = "MAPS_NETBK INBOX REPORT FOR " & Format(Now(), "Short Date")
.Body = "" & vbCrLf & vbCrLf
.Importance = olImportanceHigh 'High importance

' Add attachments to the message.
If Not IsMissing(AttachmentPath) Then
Set objOutlookAttach = .Attachments.Add(AttachmentPath)
End If

' Resolve each Recipient's name.
For Each objOutlookRecip In .Recipients
objOutlookRecip.Resolve
Next

' Should we display the message before sending?
If DisplayMsg Then
.Display
Else
.Save
.Send
End If
End With
Set objOutlook = Nothing
End Sub

Trisha
padinka@yahoo.com
 
Hi Trisha,

I believe you need to set the "SentOnBehalfOfName" property.

I took a part of your code and placed in it the format.

'*****code***
With objOutlookMsg 'excerpt from your code

' Set the "From" field
.SentOnBehalfOfName = "Jon Grande" 'example

HTH

Have A Great Day!!!, [bigglasses]

Nathan
Senior Test Lead
 
PERFECT! It works beatifully. Thanks!
Trisha
padinka@yahoo.com
 
Glad I could help! :) Have A Great Day!!!, [bigglasses]

Nathan
Senior Test Lead
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top