Your viewing of our forums and
Resources will be restricted shortly
and plus you are missing out on
many benefits, to get unrestricted
access and benefits Join here! free!

If you register all "In Post"
adverts disappear too!

Translate this Page!


If you have found this site useful
and would like to keep it going
then why not donate £0.10
Thats just 10p or 7cents!

Setting Send-From Account in VBA - Page 2 - The Code Cage Forums

The Code Cage - Microsoft Office help

 


Your Ad Here
To stop seeing these ads and get other benefits check This page!

Go Back   The Code Cage Forums > Newsgroups - Microsoft Topics > Newsgroup - Outlook Forum > Outlook Macro's & VBA
Register Code Uploads/
Downloads
FAQ's and Rules Members List Calendar Search Today's Posts Mark Forums Read
Outlook Macro's & VBA Post questions in this forum if they are related to using Microsoft Outlook VBA & Macro's to automate tasks.



Reply
 
LinkBack Thread Tools Display Modes
  #11 (permalink)  
Old 24th October 2008, 02:51 PM
Josh
Newsgroup Contributor


My Top Tip Count:

 
Posts: n/a
Default Re: Setting Send-From Account in VBA

------ Register to get rid of these "In Post" ads! ------


On Oct 23, 6:52*pm, "Dmitry Streblechenko" <dmi...@dimastr.com> wrote:
> You cannot change teh accout in teh ItemSen event.
> As was previously suggested, Cancel the event, set the appropriate account,
> then call MailItem.Send again.
>
> --
> Dmitry Streblechenko (MVP)http://www.dimastr.com/
Original Source: The Code Cage Forums http://www.thecodecage.com/forumz/outlook-macros-vba/6719-setting-send-account-visual-basic-applications-2.html#post23399
> OutlookSpy *- Outlook, CDO
> and MAPI Developer Tool
> -"Josh" <jgordon...@gmail.com> wrote in message
>
> news:534b10e3-3ad6-4efe-8a0b-be45fd0aa965@l77g2000hse.googlegroups.com...
>
> I'm not sure I understand. I know that I don't need Redemption for
> figuring out if it's a new message or reply, I got that by using the
> conversationIndex. The open question is still how to set the
> item.SendUsingAccount property in the ItemSend event or to figure out
> a way to set it earlier in the process.


I see what you mean now. The only question I have is how/when to
resend the message. In ItemSend, I set a private variable currMailItem
= item (where item is the passed in parameter to ItemSend). However,
if I set cancel = true, and then try to run item.send, it says "You
cannot send an item that is already in the process of being sent. So,
I have a handle to the mailItem, but I don't know how I can call the
Send method. Given that I don't see any timers in the control box, and
any methods I call out to would all be called within ItemSend, I'm
still at a loss of how to accomplish this. The relevant code snippet
is:

If blnAccountChanged = True Then
Cancel = True 'Cancel sending current message
blnResending = True 'Set the resending flag
Set currMailItem = item
currMailItem.Send 'THIS LINE CAUSES AN ERROR FOR TRYING TO RESEND
Exit Sub
Else
'The account didn't change, so just send as normal
Cancel = False
End If

Thanks for your help.

-Josh
Reply to this post


Did you find this post helpful? Yes | No
The Code Cage Advertisment
Advertisement

To stop seeing these ads and get other benefits check This page!
Your Ad Here
  #12 (permalink)  
Old 24th October 2008, 06:02 PM
Dmitry Streblechenko
Newsgroup Contributor


My Top Tip Count:

 
Posts: n/a
Default Re: Setting Send-From Account in VBA

------ Register to get rid of these "In Post" ads! ------


No, a signature is set only when a brand new unsent message is displayed for
the very first time.
You really do not want Outlook to silently change anything in the messge
body...

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
"Josh" <jgordon428@gmail.com> wrote in message
news:d113c6d2-f377-443f-a37d-9e1864aa8633@j22g2000hsf.googlegroups.com...
On Oct 24, 9:29 am, Josh <jgordon...@gmail.com> wrote:
> On Oct 23, 6:52 pm, "Dmitry Streblechenko" <dmi...@dimastr.com> wrote:
>
>
>
> > You cannot change teh accout in teh ItemSen event.
> > As was previously suggested, Cancel the event, set the appropriate
> > account,
> > then call MailItem.Send again.

>
> > --
> > Dmitry Streblechenko (MVP)http://www.dimastr.com/
> > OutlookSpy - Outlook, CDO
> > and MAPI Developer Tool
> > -"Josh" <jgordon...@gmail.com> wrote in message

>
> >news:534b10e3-3ad6-4efe-8a0b-be45fd0aa965@l77g2000hse.googlegroups.com...

>
> > I'm not sure I understand. I know that I don't need Redemption for
> > figuring out if it's a new message or reply, I got that by using the
> > conversationIndex. The open question is still how to set the
> > item.SendUsingAccount property in the ItemSend event or to figure out
> > a way to set it earlier in the process.

>
> I see what you mean now. The only question I have is how/when to
> resend the message. In ItemSend, I set a private variable currMailItem
> = item (where item is the passed in parameter to ItemSend). However,
> if I set cancel = true, and then try to run item.send, it says "You
> cannot send an item that is already in the process of being sent. So,
> I have a handle to the mailItem, but I don't know how I can call the
> Send method. Given that I don't see any timers in the control box, and
Original Source: The Code Cage Forums http://www.thecodecage.com/forumz/outlook-macros-vba/6719-setting-send-account-visual-basic-applications-2.html#post23695
> any methods I call out to would all be called within ItemSend, I'm
> still at a loss of how to accomplish this. The relevant code snippet
> is:
>
> If blnAccountChanged = True Then
> Cancel = True 'Cancel sending current message
> blnResending = True 'Set the resending flag
> Set currMailItem = item
> currMailItem.Send 'THIS LINE CAUSES AN ERROR FOR TRYING TO RESEND
> Exit Sub
> Else
> 'The account didn't change, so just send as normal
> Cancel = False
> End If
>
> Thanks for your help.
>
> -Josh


Sorry, one more thing I just noticed. Setting item.SendUsingAccount
doesn't update the signature. So even if I could get it to update to
the new account and resend, it would still have the signature from the
old account. Any way around this?


Reply to this post


Did you find this post helpful? Yes | No
The Code Cage Advertisment
Advertisement

To stop seeing these ads and get other benefits check This page!
Your Ad Here
  #13 (permalink)  
Old 24th October 2008, 10:32 PM
Josh
Newsgroup Contributor


My Top Tip Count:

 
Posts: n/a
Default Re: Setting Send-From Account in VBA

------ Register to get rid of these "In Post" ads! ------


On Oct 24, 12:57*pm, "Dmitry Streblechenko" <dmi...@dimastr.com>
wrote:
> No, a signature is set only when a brand new unsent message is displayed for
> the very first time.
> You really do not want Outlook to silently change anything in the messge
> body...
>
> --
> Dmitry Streblechenko (MVP)http://www.dimastr.com/
> OutlookSpy *- Outlook, CDO
> and MAPI Developer Tool
> -"Josh" <jgordon...@gmail.com> wrote in message
>
> news:d113c6d2-f377-443f-a37d-9e1864aa8633@j22g2000hsf.googlegroups.com...
> On Oct 24, 9:29 am, Josh <jgordon...@gmail.com> wrote:
>
>
>
> > On Oct 23, 6:52 pm, "Dmitry Streblechenko" <dmi...@dimastr.com> wrote:

>
> > > You cannot change teh accout in teh ItemSen event.
> > > As was previously suggested, Cancel the event, set the appropriate
> > > account,
> > > then call MailItem.Send again.

>
> > > --
> > > Dmitry Streblechenko (MVP)http://www.dimastr.com/
> > > OutlookSpy - Outlook, CDO
> > > and MAPI Developer Tool
> > > -"Josh" <jgordon...@gmail.com> wrote in message

>
> > >news:534b10e3-3ad6-4efe-8a0b-be45fd0aa965@l77g2000hse.googlegroups.com....

>
> > > I'm not sure I understand. I know that I don't need Redemption for
> > > figuring out if it's a new message or reply, I got that by using the
> > > conversationIndex. The open question is still how to set the
> > > item.SendUsingAccount property in the ItemSend event or to figure out
> > > a way to set it earlier in the process.

>
> > I see what you mean now. The only question I have is how/when to
> > resend the message. In ItemSend, I set a private variable currMailItem
> > = item (where item is the passed in parameter to ItemSend). However,
> > if I set cancel = true, and then try to run item.send, it says "You
> > cannot send an item that is already in the process of being sent. So,
> > I have a handle to the mailItem, but I don't know how I can call the
> > Send method. Given that I don't see any timers in the control box, and
> > any methods I call out to would all be called within ItemSend, I'm
> > still at a loss of how to accomplish this. The relevant code snippet
> > is:

>
> > If blnAccountChanged = True Then
> > Cancel = True 'Cancel sending current message
> > blnResending = True 'Set the resending flag
> > Set currMailItem = item
> > currMailItem.Send 'THIS LINE CAUSES AN ERROR FOR TRYING TO RESEND
> > Exit Sub
> > Else
> > 'The account didn't change, so just send as normal
> > Cancel = False
> > End If

>
> > Thanks for your help.

>
> > -Josh

>
> Sorry, one more thing I just noticed. Setting item.SendUsingAccount
> doesn't update the signature. So even if I could get it to update to
> the new account and resend, it would still have the signature from the
> old account. Any way around this?


Well, when you change the account manually on a message, it updates
the signature. So, I assumed there was a way that you could do it
programatically as well.

Any thoughts on the other question about how to resend the message
Original Source: The Code Cage Forums http://www.thecodecage.com/forumz/outlook-macros-vba/6719-setting-send-account-visual-basic-applications-2.html#post24133
after the account has been manually changed?

Thanks,
Josh
Reply to this post


Did you find this post helpful? Yes | No
  #14 (permalink)  
Old 25th October 2008, 08:24 AM
Dmitry Streblechenko
Newsgroup Contributor


My Top Tip Count:

 
Posts: n/a
Default Re: Setting Send-From Account in VBA

------ Register to get rid of these "In Post" ads! ------


Outlook changes the signature when the user sees the message and can correct
any problem.
AS for sending, it looks like Outlook prevents you from recursively calling
Original Source: The Code Cage Forums http://www.thecodecage.com/forumz/outlook-macros-vba/6719-setting-send-account-visual-basic-applications-2.html#post24365
Send: you will need to cancel the ItemSend event, store the message entry id
i n a variable, reopen the message using Namespace.GetItemFromID at a later
point (timer event handler?) and call Send again.

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
"Josh" <jgordon428@gmail.com> wrote in message
news:2d5c4e66-6cf2-4cac-97ad-2e2b4e57252f@q9g2000hsb.googlegroups.com...

Well, when you change the account manually on a message, it updates
the signature. So, I assumed there was a way that you could do it
programatically as well.

Any thoughts on the other question about how to resend the message
after the account has been manually changed?

Thanks,
Josh


Reply to this post


Did you find this post helpful? Yes | No
  #15 (permalink)  
Old 25th October 2008, 06:26 PM
Josh
Newsgroup Contributor


My Top Tip Count:

 
Posts: n/a
Default Re: Setting Send-From Account in VBA

------ Register to get rid of these "In Post" ads! ------


On Oct 24, 5:34*pm, "Dmitry Streblechenko" <dmi...@dimastr.com> wrote:
> Outlook changes the signature when the user sees the message and can correct
> any problem.
> AS for sending, it looks like Outlook prevents you from recursively calling
> Send: you will need to cancel the ItemSend event, store the message entryid
> i n a variable, reopen the message using Namespace.GetItemFromID at a later
> point (timer event handler?) and call Send again.
>
> --
> Dmitry Streblechenko (MVP)http://www.dimastr.com/
> OutlookSpy *- Outlook, CDO
> and MAPI Developer Tool
> -"Josh" <jgordon...@gmail.com> wrote in message
>
> news:2d5c4e66-6cf2-4cac-97ad-2e2b4e57252f@q9g2000hsb.googlegroups.com...
>
> Well, when you change the account manually on a message, it updates
> the signature. So, I assumed there was a way that you could do it
> programatically as well.
>
> Any thoughts on the other question about how to resend the message
> after the account has been manually changed?
>
> Thanks,
> Josh


OK, this is almost there! I used your suggestion and have a timer that
gets activated and resends the message with the updated account a
second later. The only open issue is the signature. Technically the
original message does remain open on the screen for the second between
attempting to send the first time and actually sending the second
time. Do you have any suggestions for how to best update the signature
to match the new sending account during that time? I've seen some
samples using Word bookmarks or accessing the registry, but I wasn't
sure if there was a method you recommended.
Original Source: The Code Cage Forums http://www.thecodecage.com/forumz/outlook-macros-vba/6719-setting-send-account-visual-basic-applications-2.html#post24560

Thanks again.

-Josh
Reply to this post


Did you find this post helpful? Yes | No
The Code Cage Advertisment
Advertisement

To stop seeing these ads and get other benefits check This page!
Your Ad Here
  #16 (permalink)  
Old 25th October 2008, 11:02 PM
Josh
Newsgroup Contributor


My Top Tip Count:

 
Posts: n/a
Default Re: Setting Send-From Account in VBA

------ Register to get rid of these "In Post" ads! ------


On Oct 24, 5:34*pm, "Dmitry Streblechenko" <dmi...@dimastr.com> wrote:
> Outlook changes the signature when the user sees the message and can correct
> any problem.
> AS for sending, it looks like Outlook prevents you from recursively calling
> Send: you will need to cancel the ItemSend event, store the message entryid
> i n a variable, reopen the message using Namespace.GetItemFromID at a later
> point (timer event handler?) and call Send again.
>
> --
> Dmitry Streblechenko (MVP)http://www.dimastr.com/
> OutlookSpy *- Outlook, CDO
> and MAPI Developer Tool
> -"Josh" <jgordon...@gmail.com> wrote in message
>
> news:2d5c4e66-6cf2-4cac-97ad-2e2b4e57252f@q9g2000hsb.googlegroups.com...
>
> Well, when you change the account manually on a message, it updates
> the signature. So, I assumed there was a way that you could do it
> programatically as well.
>
> Any thoughts on the other question about how to resend the message
> after the account has been manually changed?
>
> Thanks,
> Josh


Sorry if this is double-posting, I don't see my recent reply. I got
the sending portion working using a timer. This is almost complete,
Original Source: The Code Cage Forums http://www.thecodecage.com/forumz/outlook-macros-vba/6719-setting-send-account-visual-basic-applications-2.html#post24704
but the signature issue remains. Now the original message gets
canceled, the account gets changed, and then a second later it resends
with the new account. What's the best way to change the signature at
this point? Technically the email is still being displayed on screen
so the user can see the changes. I've seen some suggestions of using
word bookmarks or reading the signature directly from the registry,
but I was wondering if you had a suggestion for the best way to do
that.

Thanks,
Josh
Reply to this post


Did you find this post helpful? Yes | No
  #17 (permalink)  
Old 26th October 2008, 09:54 PM
Dmitry Streblechenko
Newsgroup Contributor


My Top Tip Count:

 
Posts: n/a
Default Re: Setting Send-From Account in VBA

------ Register to get rid of these "In Post" ads! ------


Unless you explicly remove the old signature and insert teh new onee, I
don't think there is a way to force Outlook to do that for you.

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
"Josh" <jgordon428@gmail.com> wrote in message
news:447e7776-0d0f-4e86-86ac-1b8dd6c460ea@u46g2000hsc.googlegroups.com...
On Oct 24, 5:34 pm, "Dmitry Streblechenko" <dmi...@dimastr.com> wrote:
> Outlook changes the signature when the user sees the message and can
> correct
> any problem.
> AS for sending, it looks like Outlook prevents you from recursively
> calling
> Send: you will need to cancel the ItemSend event, store the message entry
Original Source: The Code Cage Forums http://www.thecodecage.com/forumz/outlook-macros-vba/6719-setting-send-account-visual-basic-applications-2.html#post25163
> id
> i n a variable, reopen the message using Namespace.GetItemFromID at a
> later
> point (timer event handler?) and call Send again.
>
> --
> Dmitry Streblechenko (MVP)http://www.dimastr.com/
> OutlookSpy - Outlook, CDO
> and MAPI Developer Tool
> -"Josh" <jgordon...@gmail.com> wrote in message
>
> news:2d5c4e66-6cf2-4cac-97ad-2e2b4e57252f@q9g2000hsb.googlegroups.com...
>
> Well, when you change the account manually on a message, it updates
> the signature. So, I assumed there was a way that you could do it
> programatically as well.
>
> Any thoughts on the other question about how to resend the message
> after the account has been manually changed?
>
> Thanks,
> Josh


Sorry if this is double-posting, I don't see my recent reply. I got
the sending portion working using a timer. This is almost complete,
but the signature issue remains. Now the original message gets
canceled, the account gets changed, and then a second later it resends
with the new account. What's the best way to change the signature at
this point? Technically the email is still being displayed on screen
so the user can see the changes. I've seen some suggestions of using
word bookmarks or reading the signature directly from the registry,
but I was wondering if you had a suggestion for the best way to do
that.

Thanks,
Josh


Reply to this post


Did you find this post helpful? Yes | No
  #18 (permalink)  
Old 28th October 2008, 03:24 PM
Josh
Newsgroup Contributor


My Top Tip Count:

 
Posts: n/a
Default Re: Setting Send-From Account in VBA

------ Register to get rid of these "In Post" ads! ------


On Oct 26, 4:14*pm, "Dmitry Streblechenko" <dmi...@dimastr.com> wrote:
Original Source: The Code Cage Forums http://www.thecodecage.com/forumz/outlook-macros-vba/6719-setting-send-account-visual-basic-applications-2.html#post27040
> Unless you explicly remove the old signature and insert teh new onee, I
> don't think there is a way to force Outlook to do that for you.
>
> --
> Dmitry Streblechenko (MVP)http://www.dimastr.com/
> OutlookSpy *- Outlook, CDO
> and MAPI Developer Tool
> -"Josh" <jgordon...@gmail.com> wrote in message
>
> news:447e7776-0d0f-4e86-86ac-1b8dd6c460ea@u46g2000hsc.googlegroups.com...
> On Oct 24, 5:34 pm, "Dmitry Streblechenko" <dmi...@dimastr.com> wrote:
>
>
>
> > Outlook changes the signature when the user sees the message and can
> > correct
> > any problem.
> > AS for sending, it looks like Outlook prevents you from recursively
> > calling
> > Send: you will need to cancel the ItemSend event, store the message entry
> > id
> > i n a variable, reopen the message using Namespace.GetItemFromID at a
> > later
> > point (timer event handler?) and call Send again.

>
> > --
> > Dmitry Streblechenko (MVP)http://www.dimastr.com/
> > OutlookSpy - Outlook, CDO
> > and MAPI Developer Tool
> > -"Josh" <jgordon...@gmail.com> wrote in message

>
> >news:2d5c4e66-6cf2-4cac-97ad-2e2b4e57252f@q9g2000hsb.googlegroups.com...

>
> > Well, when you change the account manually on a message, it updates
> > the signature. So, I assumed there was a way that you could do it
> > programatically as well.

>
> > Any thoughts on the other question about how to resend the message
> > after the account has been manually changed?

>
> > Thanks,
> > Josh

>
> Sorry if this is double-posting, I don't see my recent reply. I got
> the sending portion working using a timer. This is almost complete,
> but the signature issue remains. Now the original message gets
> canceled, the account gets changed, and then a second later it resends
> with the new account. What's the best way to change the signature at
> this point? Technically the email is still being displayed on screen
> so the user can see the changes. I've seen some suggestions of using
> word bookmarks or reading the signature directly from the registry,
> but I was wondering if you had a suggestion for the best way to do
> that.
>
> Thanks,
> Josh


OK, explicitly removing and inserting is fine. However, I'm not sure
how to get started in terms of:
1) Locating the existing signature in the message and removing it
(given that I will have to determine where the signature block is,
since the text could be anything).
2) Determining which signature goes with the newly selected account
3) Inserting the new signature at the correct location.

Any ideas to get me started?

Thanks,
Josh
Reply to this post


Did you find this post helpful? Yes | No
The Code Cage Advertisment
Advertisement

To stop seeing these ads and get other benefits check This page!
Your Ad Here
  #19 (permalink)  
Old 28th October 2008, 07:13 PM
Dmitry Streblechenko
Newsgroup Contributor


My Top Tip Count:

 
Posts: n/a
Default Re: Setting Send-From Account in VBA

------ Register to get rid of these "In Post" ads! ------


Are you sure you really, really want to do that?
Just to give you an example, if you start typing and then select a different
account, chances are you typed in an area that Outlook considers to be the
signature and wipes out your text. Happens to me about 50% of the time.
Luckily, Edit | Undo works fine.
If you do something like that after the user clicked Send and has no chance
to undo the changes or even be aware that something happened, you'll have a
large crowd of very, very unhappy customers.
In other words, don't do that.

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
"Josh" <jgordon428@gmail.com> wrote in message
news:be860868-3477-4b49-bd96-46054bc038f9@h60g2000hsg.googlegroups.com...

OK, explicitly removing and inserting is fine. However, I'm not sure
how to get started in terms of:
1) Locating the existing signature in the message and removing it
(given that I will have to determine where the signature block is,
since the text could be anything).
2) Determining which signature goes with the newly selected account
3) Inserting the new signature at the correct location.

Any ideas to get me started?
Original Source: The Code Cage Forums http://www.thecodecage.com/forumz/outlook-macros-vba/6719-setting-send-account-visual-basic-applications-2.html#post27484

Thanks,
Josh


Reply to this post


Did you find this post helpful? Yes | No
The Code Cage Advertisment
Advertisement

To stop seeing these ads and get other benefits check This page!
Your Ad Here
Reply

Bookmarks

Tags
account, sendfrom, setting, vba

New topics in Outlook Macro's & VBA


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

The Code Cage Affilliates


To stop seeing these ads and get other benefits check This page!



All times are GMT +1. The time now is 03:33 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.3.2
No part of this board may be copied or reproduced either in part or full without the express permission of The Code Cage Team.
We are not associated with nor employed by Microsoft in any way, we simply provide resources!
All MS office icons are registered trademarks of the application the represent