Hi,
I'm trying to send a mail using Word-VBA using Outlook. But I have to
use a special account (German: Konto) (not my default mail address).
This account already exists in Outlook, and it does send and receive
mails, and it can be selected using the "Account"-Button when creating a
new mail manually.
But how about automation? How can I select the account using VBA?
Example (using Word VBA):
Set oOutlook = CreateObject("Outlook.Application")
If ActiveDocument.Saved = False Then ActiveDocument.Save
Set oiMail = oOutlook.CreateItem(0) ' New e-mail
With oiMail ' define outlook object
.Subject = "Fax to " & faxnr
.Body = ""
.To = faxnr & "@internetfaxservice.eg"
.Account = "tom.stein@myfaxaccountname.de" ' <<< VBA-Help says
".Account" exists, but it does not!
.Attachments.Add ActiveDocument.FullName, 1, 1, "Fax"
.Display
On Error Resume Next
.Send ' Gets a runtime error if user does not allow to send mail
from word using vba
End With
Set oiMail = Nothing ' Clean up
Set oOutlook = Nothing
Ciao, Tom
jaf - 23 Nov 2005 19:04 GMT
Hi Tom,
Account is a property of the contact (recipient) not the sender.
John
> Hi,
>
[quoted text clipped - 27 lines]
>
> Ciao, Tom
Thomas Stein - 23 Nov 2005 21:10 GMT
> Hi Tom,
> Account is a property of the contact (recipient) not the sender.
It is, so that is why my code won't work. But what ist the right why to
tell Outlook to use the right sender/account for an outgoing message?
Does really noone know?
Ciao, Tom
Dmitry Streblechenko - 23 Nov 2005 21:29 GMT
Outlook does not expose accounts used to receive/send e-mail.
<plug>Redemption (url) below exposes this functionality through the
RDOMail.Account property - see http://www.dimastr.com/redemption/rdo/</plug>
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
>> Hi Tom,
>> Account is a property of the contact (recipient) not the sender.
[quoted text clipped - 4 lines]
>
> Ciao, Tom
Thomas Stein - 23 Nov 2005 21:23 GMT
> I'm trying to send a mail using Word-VBA using Outlook. But I have to
> use a special account (German: Konto) (not my default mail address).
Does anyone know the book
Microsoft Outlook Programming
Jumpstart for Administrators, Developers, and Power Users
?
In Chapter 21 I see a chapter "Sending with a particular account
(Outlook 2002)". Does it solve the problem? If so, I will order it. But
as English Books are not in the normal stores in Germany, I'm afraid I
can not check it before buying. So even a readers hint whether it's
worth buying would help ;-)
Tom
Sue Mosher [MVP-Outlook] - 25 Nov 2005 16:56 GMT
Outlook doesn't provide any direct way to change the account for an outgoing message. See
http://www.outlookcode.com/codedetail.aspx?id=889 for various workarounds that might fit your scenario.

Signature
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/jumpstart.aspx
> Hi,
>
[quoted text clipped - 27 lines]
>
> Ciao, Tom
Thomas Stein - 01 Dec 2005 23:20 GMT
> Outlook doesn't provide any direct way to change the account for an
> outgoing message. See
> http://www.outlookcode.com/codedetail.aspx?id=889 for various
> workarounds that might fit your scenario.
Thank you, Microsoft seems to have lost the way - at least the right way
to control all mail properties - but those workarounds do help.
Tom