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
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