Setting Account for Mails

T

Thomas Stein

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 = "(e-mail address removed)" ' <<< 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
 
T

Thomas Stein

jaf said:
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
 
T

Thomas Stein

Thomas said:
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
 
S

Sue Mosher [MVP-Outlook]

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.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 

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