RogerCooper
Registered User.
- Local time
- Today, 07:03
- Joined
- Jul 30, 2014
- Messages
- 286
I discovered that I did not have the proper object library. So for early binding, I have the following code:
This fails on "Set olAccount = oLook.account" with the error "object doesn't support this property or method". What I am doing wrong?
Code:
Sub doEmailOutlook()
Dim oLook As Object
Dim oMail As Outlook.MailItem
Dim olAccount As Variant
Dim olAccounts As Variant
Set oLook = CreateObject("Outlook.Application")
Set oMail = oLook.CreateItem(0)
Set olAccount = oLook.account
Set olAccounts = oLook.application.Session.accounts
Set olAccountTemp = oLook.account
Dim strEmail As String
Dim strMsg As String
Dim foundAccount As Boolean
Dim strFrom As String
foundAccount = False
strFrom = "[EMAIL="ar@spectroline.com"]ar@spectroline.com[/EMAIL]"
Set olAccounts = oLook.application.Session.accounts
For Each olAccountTemp In olAccounts
If (olAccountTemp.smtpAddress = strFrom) Then
Set olAccount = olAccountTemp
foundAccount = True
Debug.Print olAccountTemp.smtpAddress
Exit For
End If
Next
This fails on "Set olAccount = oLook.account" with the error "object doesn't support this property or method". What I am doing wrong?