Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 06-20-2023, 06:26 AM
MikeK MikeK is offline Error when sending email from Excel using an Outlook.account identified by its email address. Windows 7 64bit Error when sending email from Excel using an Outlook.account identified by its email address. Office 2013
Novice
Error when sending email from Excel using an Outlook.account identified by its email address.
 
Join Date: Aug 2020
Posts: 9
MikeK is on a distinguished road
Default Error when sending email from Excel using an Outlook.account identified by its email address.

I send email from within Excel where I determine which of a number of outlook accounts should be used to send the mail. I have always done this using early binding and I have no problem, however I am currently knocking up a workbook where I want to use late binding and have encountered a problem.
Identifying the account by it's account number works in both early and late binding. Identifying the account from it's email address works in early binding but fails in late binding.


Early Binding works fine as in the two following procedures:

Sub EarlyBindingChangeAccountByNumber()
Dim OutApp As Outlook.application
Dim OutMail As Outlook.MailItem
Dim OutAccount As Outlook.account

Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(olMailItem)
Set OutAccount = OutApp.Session.accounts.Item(1)

With OutMail
.SendUsingAccount = OutAccount
.Display


End With
End Sub

Sub EarlyBindingChangeAccountByName()
Dim OutApp As Outlook.application
Dim OutMail As Outlook.MailItem
Dim OutAccount As Outlook.account

Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(olMailItem)
Set OutAccount = OutApp.Session.accounts("myaddress@gmail.com")

With OutMail
.SendUsingAccount = OutAccount
.Display
End With
End Sub


Late binding works fine in the first of the following procedures but not in the second.

Sub LateBindingChangeAccountByNumber()
Dim OutApp As Object
Dim OutMail As Object
Dim OutAccount As Object

Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
Set OutAccount = OutApp.Session.accounts.Item(1)

With OutMail
Set .SendUsingAccount = OutAccount
.Display
End With
End Sub

However I get this error on the Set OutAccount line when i specify the email address for the account.
Run-time error '450':
Wrong number of arguments or invalid property assignment

Sub LateBindingChangeAccountByName()
Dim OutApp As Object
Dim OutMail As Object
Dim OutAccount As Object

Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
Set OutAccount = OutApp.Session.accounts("myaddress@gmail.com")

With OutMail
Set .SendUsingAccount = OutAccount
.Display
End With
End Sub


Any enlightement on this would be gratefully recieved.
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Error when sending email from Excel using an Outlook.account identified by its email address. change from address when sending email kitelooper Outlook 7 02-14-2020 01:53 AM
when sending email pick email address 1 2 or 3 from the person contact. red_dog2 Outlook 1 06-15-2017 07:56 PM
How to prevent exchange email account from sending emails in Outlook igii05 Outlook 0 01-24-2014 05:37 PM
outlook - sending/replying with second email on account smitty0476 Outlook 0 08-08-2013 09:49 AM
outlook.com account in Outlook 2007 freezes at 93% sending/receiving email ink8 Outlook 0 10-10-2012 12:19 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 09:35 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft