Re: .sendusingaccount ? for OL 2007

Tech-Archive recommends: Speed Up your PC by fixing your registry



Namespace is the name of the object, in other words the class, that you need to use, not the name of an object variable in your application. You need to instantiate a Namespace object using the Outlook object model's Application.GetNamespace method.
--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/article.aspx?id=54

"Bruce" <newsgroups@xxxxxxxxxxxxxxx> wrote in message news:OM2dKfJpHHA.1240@xxxxxxxxxxxxxxxxxxxxxxx
Sue,

Thank you for your help. I made the change to
.SendUsingAccount = namespace.Accounts(3)

but now I am getting RT error 424
Object required

Againg this is being thrown on the line:
.SendUsingAccount = Namespace.Accounts(3)

Also, just to be clear (I did not put it in my first post) this is in EXCEL!

Thanks again
Bruce





"Sue Mosher [MVP-Outlook]" <suemvp@xxxxxxxxxxxxxxx> wrote in message
news:umjoIsIpHHA.4212@xxxxxxxxxxxxxxxxxxxxxxx
The object browser is our friend. It's Namespace.Acccounts, not
Application.Accounts. Good way to remember: Anything that is dependent on
mail profile settings derives from the Namespace object.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/article.aspx?id=54

"Bruce" <newsgroups@xxxxxxxxxxxxxxx> wrote in message
news:uSi1DjIpHHA.3944@xxxxxxxxxxxxxxxxxxxxxxx
'K
I commented out the on error, and now I am getting an error.
run-time error '438':
Object doesn't support this program or method.

I DO have Outlook 12 selected in tool>references
.SendUsingAccount = OutApp.Accounts(3)

is the line that throws the error.

Here is how the code block is right now:

Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
Set OutMail = OutApp.CreateItem(0)

' On Error Resume Next
With OutMail
.To = emailname
.CC = ""
.BCC = bbcname
.SendUsingAccount = OutApp.Accounts(3)

.Subject = "Invoice for - " & Range("L6").Value & " - " &
Application.Text(Range("L4").Value, "mmm-dd-yyyy")
.HTMLBody = RangetoHTML(rng)
.Send 'or use .Display

End With

What am I missing?
I HAVE gotten the following code working, and msgbox oAccount shows me the
account name for each loop.

Dim oAccount As Outlook.Account

' For Each oAccount 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 emailname
' oMail.Recipients.ResolveAll
' oMail.SendUsingAccount = oAccount
' oMail.Send
' MsgBox oAccount
'
' End If
' Next



Thanks
Bruce

"Sue Mosher [MVP-Outlook]" <suemvp@xxxxxxxxxxxxxxx> wrote in message
news:ePFuXsHpHHA.1240@xxxxxxxxxxxxxxxxxxxxxxx
OutApp.Accounts(3) returns an Account object.
I would comment out the On Error Resume Next statement to make sure an
error
isn't being overlooked.


"Bruce" <newsgroups@xxxxxxxxxxxxxxx> wrote in message
news:%23SOeyxGpHHA.2452@xxxxxxxxxxxxxxxxxxxxxxx
Hello Sue,

I have tried moving it up in the code block, but I still can not change
the
account.
What am I missing?

I know you have told others that it needs to be an object, but how do I
do
that? Is it going to be an object the way I have my code written?
I KNOW I am close, but....

Thanks
Bruce

"Sue Mosher [MVP-Outlook]" <suemvp@xxxxxxxxxxxxxxx> wrote in message
news:eZhN$YGpHHA.3644@xxxxxxxxxxxxxxxxxxxxxxx
You need to set SendUsingAccount before you send the item.


"Bruce" <newsgroups@xxxxxxxxxxxxxxx> wrote in message
news:unwpG8FpHHA.588@xxxxxxxxxxxxxxxxxxxxxxx
I have tried to research this and I can not find much.

Here is the code I have. It still sends from the defualt account. I have
21
email accounts and this is to be sending from the 21st account. I in the
below code, I have tried using from the 3r account.

Sub Mail_Selection_Range_Outlook_Body()
' Don't forget to copy the function RangetoHTML in the module.
' Working in Office 2000-2007
Dim rng As Range
Dim OutApp As Object
Dim OutMail As Object

With Application
.EnableEvents = False
.ScreenUpdating = False
End With

Set rng = Nothing
On Error Resume Next
'Only the visible cells in the selection
'Set rng = Selection.SpecialCells(xlCellTypeVisible)
'You can also use a range if you want
Set rng =
Sheets("Invoice").Range("B7:I47").SpecialCells(xlCellTypeVisible)
emailname = Range("M21").Value
bbcname = "invoices@xxxxxxxxxxxxxxxxxxxxx"
MsgBox emailname


On Error GoTo 0

If rng Is Nothing Then
MsgBox "The selection is not a range or the *** is protected" &
_
vbNewLine & "please correct and try again.", vbOKOnly
Exit Sub
End If

Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
Set OutMail = OutApp.CreateItem(0)

On Error Resume Next
With OutMail
.To = emailname
.CC = ""
.BCC = bbcname
.Subject = "Invoice for - " & Range("L6").Value & " - " &
Application.Text(Range("L4").Value, "mmm-dd-yyyy")
.HTMLBody = RangetoHTML(rng)
.Send 'or use .Display
.SendUsingAccount = OutApp.Accounts(3)

End With
On Error GoTo 0

With Application
.EnableEvents = True
.ScreenUpdating = True
End With

Set OutMail = Nothing
Set OutApp = Nothing
End Sub




.


Quantcast