B
Bob Lovler
I had the need to be able to select a specific POP3 account in Outlook
by code for an application I was developing. After reading all the
posts regarding this topic I discovered that it was not possible to do
so.
However, after working on the problem for a while, I developed a
method seems to work well (at least for me). I acknowledge that it is
not an "elegent" method, but as I am not a programmer by trade,
function was more important to me than form.
Here's what I came up with:
1. For every POP3 account that I have, I first send a message to
myself choosing the account that I want it to be sent from in the
normal, manual method. The to, subject and body of this message do
not matter as they will be changed via code later. Each email that I
send will ultimately serve as blank "templates" for a particular
account.
2. After the emails are sent, they will of course be in your "Sent
Items" folder. Create a new folder (name it anything you wish) and
move the "template" emails from the Sent Items folder into the new
folder.
3. Now when you wish to send an email ny code from a particular
account here's all you need to do:
a. Iterate through the items in the template folder to find the
".SenderName" of the account that you want to send your new message
via.
b. Create a copy of that item in the same folder. This is necessary
so that you always have the original template in the folder as the
item will be automatically moved to the Sent Items folder after it is
sent.
c. If you are using Outlook Redemption to bypass the security
prompts, create a "safeitem" reference to this copy
(SafeItem.Item=CopyOfTemplateItem)
d. Now you can set all the safeitem propereties (To, Body etc)to
anything you wish.
e. Send the item either with "SafeItem.Send", or if necessary for
your installation, with "SafeItem.Send" followed by "clicking" the
"send" button via code as described in the Redemption FAQ's. Because
I use a large number of accounts, I actually iterate through the
command bar "tools" menu to identify the account from which I want to
send and only "execute" the "click" for that particular account. This
way I don't waste bandwidth requesting send/receive info from accounts
that I'm not currently interested in.
What is happenening is that you are really resending an item that
already has been set-up to come from a specific account. When you
"resend" it, it will always go out using the same account that first
sent it, even if the body and addresses have been changed via code.
That's all there is to it. Like I said, it's not elegant, but it
worked for me.
by code for an application I was developing. After reading all the
posts regarding this topic I discovered that it was not possible to do
so.
However, after working on the problem for a while, I developed a
method seems to work well (at least for me). I acknowledge that it is
not an "elegent" method, but as I am not a programmer by trade,
function was more important to me than form.
Here's what I came up with:
1. For every POP3 account that I have, I first send a message to
myself choosing the account that I want it to be sent from in the
normal, manual method. The to, subject and body of this message do
not matter as they will be changed via code later. Each email that I
send will ultimately serve as blank "templates" for a particular
account.
2. After the emails are sent, they will of course be in your "Sent
Items" folder. Create a new folder (name it anything you wish) and
move the "template" emails from the Sent Items folder into the new
folder.
3. Now when you wish to send an email ny code from a particular
account here's all you need to do:
a. Iterate through the items in the template folder to find the
".SenderName" of the account that you want to send your new message
via.
b. Create a copy of that item in the same folder. This is necessary
so that you always have the original template in the folder as the
item will be automatically moved to the Sent Items folder after it is
sent.
c. If you are using Outlook Redemption to bypass the security
prompts, create a "safeitem" reference to this copy
(SafeItem.Item=CopyOfTemplateItem)
d. Now you can set all the safeitem propereties (To, Body etc)to
anything you wish.
e. Send the item either with "SafeItem.Send", or if necessary for
your installation, with "SafeItem.Send" followed by "clicking" the
"send" button via code as described in the Redemption FAQ's. Because
I use a large number of accounts, I actually iterate through the
command bar "tools" menu to identify the account from which I want to
send and only "execute" the "click" for that particular account. This
way I don't waste bandwidth requesting send/receive info from accounts
that I'm not currently interested in.
What is happenening is that you are really resending an item that
already has been set-up to come from a specific account. When you
"resend" it, it will always go out using the same account that first
sent it, even if the body and addresses have been changed via code.
That's all there is to it. Like I said, it's not elegant, but it
worked for me.