Setting Account for Mails

  • Thread starter Thread starter Thomas Stein
  • Start date Start date
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
 
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
 
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
 
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
 
Back
Top