SendUsingAccount - Office 2007

R

Rosemary

I basically copied the code from
http://msdn.microsoft.com/en-us/library/bb207787.aspx
to try to set the "From" in an email to an email address of my choice.
I can't make it work. It is word for word from the web site, except for my
e-mail address in the Receipients.add and setting the value for oAccount.
When I compile it I get an error "Method or data member not found" on the
..session
I've looked in the object explorer and it is valid.
I added references for anything Outlook.

What am I doing wrong?

Private Sub SendUsingAccount_Click()
Dim oAccount As Outlook.Account

oAccount = "(e-mail address removed)"

For Each objNamespace In Application.Session.Accounts
If oAccount.AccountType = olPop3 Then
Dim oMail As Outlook.MailItem
Set oMail = Application.CreateItem(olMailItem)
oMail.Subject = "Sent using POP3 Account"
oMail.Recipients.Add ("(e-mail address removed)")
oMail.Recipients.ResolveAll
oMail.SendUsingAccount = oAccount
oMail.Send
End If
Next
End Sub
 
T

TonyT

Hi Rosemary,

It sounds like a reference problem to me. Check that you have a reference to
OLE Automation ticked in vb Tools>References, unless you have 2007 in which
case I believe it's part of the Microsoft Office Office 12 Object Library
which should be ticked anyway.
 
R

Rosemary

Thanks for your quick response. I double checked my references, I actually
had recently added the Microsoft Office Outlook 12.0 Object Library, because
I couldn't see the Outlook library in the Object Browser. I do have both OLE
Automation, MS Office 12.0 Object Library checked. I had also added MS
Office Outlook View Control hoping that would help.

Any help is appreciated!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top