View Single Post
  #4  
Old November 20th 07, 12:53 AM posted to microsoft.public.outlook.program_vba
JP[_2_]
external usenet poster
 
Posts: 18
Default Automating Outlook from within Access

It's a property of the MailItem so you would need to include it in the
appropriate With statement. I added it into your code below. Note that
the "send on behalf of" option only works if you are set up with the
authority to send emails on behalf of someone else. If you aren't set
up as a delegate for that user/mailbox, the email may not be sent.


Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim objOutlookAttach As Outlook.Attachment


Dim mMgrAddy As String
Dim mEmpAddy As String


mBody = "This is test of the olOriginator MailItem"


' 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(mEmpAddy)
objOutlookRecip.Type = olTo

.SentOnBehalfOfName = "

' Add the From recipient(s) to the message.
Set objOutlookRecip = .Recipients.Add(mMgrAddy)
objOutlookRecip.Type = olBCC


' Set the Subject, Body, and Importance of the message.
.Subject = "This is a TEST Email"
.Body = mBody & vbCrLf & vbCrLf
.Importance = olImportanceHigh 'High importance


' 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



HTH,
JP



On Nov 19, 5:47 pm, Tylendal
wrote:
Thank you...

I was trying to find this property without success. Would it be possibe for
you to supply me with simple syntax for its use.

Thanks
Fred Alyea

Ads