The Code Cage - Microsoft Office help Free Microsoft Office Help for all Applications!  

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
  Microsoft Office Chat Online now!


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
  #1 (permalink)  
Old 23rd October 2008, 04:14 PM
Josh
Newsgroup Contributor


My Top Tip Count:

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

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


Like many other posters I've seen, I sometimes send mail from the
wrong account in Outlook 2007. I wanted to create a macro that when I
sent a message, would prompt me to verify the sending account, and let
me change if necessary.

I have the following code:
Private Sub Application_ItemSend(ByVal item As Object, Cancel As
Boolean)

If TypeOf item Is Outlook.MailItem Then
'Show form that displays account list and sets
item.SendUsingAccount

'To debug, verify it's using the right account:
msgbox item.SendUsingAccount
End if

End Sub

The routine works in the sense that it displays the list of accounts,
and sets the item.SendUsingAccount value properly (the messagebox
'Original Source: The Code Cage Forums http://www.thecodecage.com/forumz/outlook-macros-vba/6719-setting-send-account-visual-basic-applications.html#post22183
displays the correct value). However, it goes through and sends the
mail from the originally selected account anyways. It seems like once
you get to the ItemSend event, it's too late to change the account for
the current message if it gets sent. However, if something interrupts
the sending process (like another check for having a subject that
could set cancel = TRUE and cancel the sending, or stepping through
the code in debug mode), it will actually update the sending account
(which I can see reflected in the message window, cause it didn't
actually send).

My question is... is there any way to update the SendUsingAccount
property once you get to the ItemSend event? If not, is there an
earlier place to trap this event? Is there a way to trap the event of
clicking the send button and then running this code?

Thanks in advance.
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!
  #2 (permalink)  
Old 23rd October 2008, 04:14 PM
Jan Hyde (VB MVP)
Newsgroup Contributor


My Top Tip Count:

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

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


Josh <jgordon428@gmail.com>'s wild thoughts were released on
Thu, 23 Oct 2008 07:25:02 -0700 (PDT) bearing the following
fruit:

>Like many other posters I've seen, I sometimes send mail from the
>wrong account in Outlook 2007. I wanted to create a macro that when I
>sent a message, would prompt me to verify the sending account, and let
>me change if necessary.
>
>I have the following code:
>Private Sub Application_ItemSend(ByVal item As Object, Cancel As
>Boolean)
>
>If TypeOf item Is Outlook.MailItem Then
> 'Show form that displays account list and sets
>item.SendUsingAccount
>
> 'To debug, verify it's using the right account:
> msgbox item.SendUsingAccount
>End if
>
>End Sub
>
>The routine works in the sense that it displays the list of accounts,
>and sets the item.SendUsingAccount value properly (the messagebox
>displays the correct value). However, it goes through and sends the
'Original Source: The Code Cage Forums http://www.thecodecage.com/forumz/outlook-macros-vba/6719-setting-send-account-visual-basic-applications.html#post22185
>mail from the originally selected account anyways. It seems like once
>you get to the ItemSend event, it's too late to change the account for
>the current message if it gets sent. However, if something interrupts
>the sending process (like another check for having a subject that
>could set cancel = TRUE and cancel the sending, or stepping through
>the code in debug mode), it will actually update the sending account
>(which I can see reflected in the message window, cause it didn't
>actually send).
>
>My question is... is there any way to update the SendUsingAccount
>property once you get to the ItemSend event? If not, is there an
>earlier place to trap this event? Is there a way to trap the event of
>clicking the send button and then running this code?
>
>Thanks in advance.


Why not set 'Cancel' yourself, set the properties you want
to change and resend.

You'll need some sort of flag to prevent being prompted on
the resend of course.


--
Jan Hyde (VB MVP)

https://mvp.support.microsoft.com/profile/Jan.Hyde
Reply to this post


Did you find this post helpful? Yes | No
  #3 (permalink)  
Old 23rd October 2008, 07:32 PM
Josh
Newsgroup Contributor


My Top Tip Count:

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

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


On Oct 23, 11:09*am, "Jan Hyde (VB MVP)"
<StellaDrin...@REMOVE.ME.uboot.com> wrote:
> Josh <jgordon...@gmail.com>'s wild thoughts were released on
> Thu, 23 Oct 2008 07:25:02 -0700 (PDT) bearing the following
> fruit:
>
>
>
> >Like many other posters I've seen, I sometimes send mail from the
> >wrong account in Outlook 2007. I wanted to create a macro that when I
> >sent a message, would prompt me to verify the sending account, and let
> >me change if necessary.

>
> >I have the following code:
> >Private Sub Application_ItemSend(ByVal item As Object, Cancel As
> >Boolean)

>
> >If TypeOf item Is Outlook.MailItem Then
> > * 'Show form that displays account list and sets
> >item.SendUsingAccount

>
> > * 'To debug, verify it's using the right account:
> > * *msgbox item.SendUsingAccount
> >End if

>
> >End Sub

>
> >The routine works in the sense that it displays the list of accounts,
> >and sets the item.SendUsingAccount value properly (the messagebox
> >displays the correct value). However, it goes through and sends the
> >mail from the originally selected account anyways. It seems like once
> >you get to the ItemSend event, it's too late to change the account for
> >the current message if it gets sent. However, if something interrupts
> >the sending process (like another check for having a subject that
> >could set cancel = TRUE and cancel the sending, or stepping through
> >the code in debug mode), it will actually update the sending account
> >(which I can see reflected in the message window, cause it didn't
> >actually send).

>
> >My question is... is there any way to update the SendUsingAccount
> >property once you get to the ItemSend event? If not, is there an
> >earlier place to trap this event? Is there a way to trap the event of
> >clicking the send button and then running this code?

>
> >Thanks in advance.

>
> Why not set 'Cancel' yourself, set the properties you want
'Original Source: The Code Cage Forums http://www.thecodecage.com/forumz/outlook-macros-vba/6719-setting-send-account-visual-basic-applications.html#post22526
> to change and resend.
>
> You'll need some sort of flag to prevent being prompted on
> the resend of course.
>
> --
> Jan Hyde (VB MVP)
>
> https://mvp.support.microsoft.com/profile/Jan.Hyde


Well, that's what I had to settle for. I now just display a message
"Are you sure you want to send from account: ACCOUNT_NAME" OK/Cancel.
However, I was wondering if there was a more elegant solution.

As a follow-up, is there a way to know if a message is a new message
or a reply/forward? I don't really need to perform this check if I'm
simply replying to a message, it's more important for a new message.

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!
  #4 (permalink)  
Old 23rd October 2008, 07:32 PM
JP
Newsgroup Contributor


My Top Tip Count:

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

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


There are a couple of threads on the issue, and I can't locate them at
the moment, but I believe the consensus was you needed to use
Redemption to do this. I can try to locate them if you really want an
accurate answer.

Regarding your followup question, you would need to check the
ConversationIndex to see if there is an existing message. See
http://www.outlookcode.com/codedetail.aspx?id=1714 for code sample. As
an alternative, you could check if Left$(MailItem.Subject, 3) = "RE:"

HTH,
JP


On Oct 23, 12:50*pm, Josh <jgordon...@gmail.com> wrote:
> On Oct 23, 11:09*am, "Jan Hyde (VB MVP)"
>
>
>
>
>
> <StellaDrin...@REMOVE.ME.uboot.com> wrote:
> > Josh <jgordon...@gmail.com>'s wild thoughts were released on
> > Thu, 23 Oct 2008 07:25:02 -0700 (PDT) bearing the following
> > fruit:

>
> > >Like many other posters I've seen, I sometimes send mail from the
> > >wrong account in Outlook 2007. I wanted to create a macro that when I
> > >sent a message, would prompt me to verify the sending account, and let
> > >me change if necessary.

>
> > >I have the following code:
> > >Private Sub Application_ItemSend(ByVal item As Object, Cancel As
> > >Boolean)

>
> > >If TypeOf item Is Outlook.MailItem Then
> > > * 'Show form that displays account list and sets
> > >item.SendUsingAccount

>
> > > * 'To debug, verify it's using the right account:
> > > * *msgbox item.SendUsingAccount
> > >End if

>
> > >End Sub

>
> > >The routine works in the sense that it displays the list of accounts,
> > >and sets the item.SendUsingAccount value properly (the messagebox
> > >displays the correct value). However, it goes through and sends the
> > >mail from the originally selected account anyways. It seems like once
> > >you get to the ItemSend event, it's too late to change the account for
> > >the current message if it gets sent. However, if something interrupts
> > >the sending process (like another check for having a subject that
> > >could set cancel = TRUE and cancel the sending, or stepping through
'Original Source: The Code Cage Forums http://www.thecodecage.com/forumz/outlook-macros-vba/6719-setting-send-account-visual-basic-applications.html#post22528
> > >the code in debug mode), it will actually update the sending account
> > >(which I can see reflected in the message window, cause it didn't
> > >actually send).

>
> > >My question is... is there any way to update the SendUsingAccount
> > >property once you get to the ItemSend event? If not, is there an
> > >earlier place to trap this event? Is there a way to trap the event of
> > >clicking the send button and then running this code?

>
> > >Thanks in advance.

>
> > Why not set 'Cancel' yourself, set the properties you want
> > to change and resend.

>
> > You'll need some sort of flag to prevent being prompted on
> > the resend of course.

>
> > --
> > Jan Hyde (VB MVP)

>
> >https://mvp.support.microsoft.com/profile/Jan.Hyde

>
> Well, that's what I had to settle for. I now just display a message
> "Are you sure you want to send from account: ACCOUNT_NAME" OK/Cancel.
> However, I was wondering if there was a more elegant solution.
>
> As a follow-up, is there a way to know if a message is a new message
> or a reply/forward? I don't really need to perform this check if I'm
> simply replying to a message, it's more important for a new message.
>
> Thanks,
> Josh- Hide quoted text -
>
> - Show quoted text -


Reply to this post


Did you find this post helpful? Yes | No
  #5 (permalink)  
Old 23rd October 2008, 07:32 PM
Dmitry Streblechenko
Newsgroup Contributor


My Top Tip Count:

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

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


Look at the ConversationIndex property - for new messages it will be 44
characters long (22 byte for the raw PR_CONVERSATION_INDEX binary property).

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
"JP" <jp2112@earthlink.net> wrote in message
news:2deca1b0-d765-44fe-917a-ba69b387dc58@h60g2000hsg.googlegroups.com...
There are a couple of threads on the issue, and I can't locate them at
the moment, but I believe the consensus was you needed to use
Redemption to do this. I can try to locate them if you really want an
accurate answer.

Regarding your followup question, you would need to check the
ConversationIndex to see if there is an existing message. See
http://www.outlookcode.com/codedetail.aspx?id=1714 for code sample. As
an alternative, you could check if Left$(MailItem.Subject, 3) = "RE:"

HTH,
JP


On Oct 23, 12:50 pm, Josh <jgordon...@gmail.com> wrote:
> On Oct 23, 11:09 am, "Jan Hyde (VB MVP)"
>
>
>
>
>
> <StellaDrin...@REMOVE.ME.uboot.com> wrote:
> > Josh <jgordon...@gmail.com>'s wild thoughts were released on
> > Thu, 23 Oct 2008 07:25:02 -0700 (PDT) bearing the following
> > fruit:

>
> > >Like many other posters I've seen, I sometimes send mail from the
> > >wrong account in Outlook 2007. I wanted to create a macro that when I
> > >sent a message, would prompt me to verify the sending account, and let
> > >me change if necessary.

>
> > >I have the following code:
> > >Private Sub Application_ItemSend(ByVal item As Object, Cancel As
> > >Boolean)

>
> > >If TypeOf item Is Outlook.MailItem Then
> > > 'Show form that displays account list and sets
> > >item.SendUsingAccount

'Original Source: The Code Cage Forums http://www.thecodecage.com/forumz/outlook-macros-vba/6719-setting-send-account-visual-basic-applications.html#post22530
>
> > > 'To debug, verify it's using the right account:
> > > msgbox item.SendUsingAccount
> > >End if

>
> > >End Sub

>
> > >The routine works in the sense that it displays the list of accounts,
> > >and sets the item.SendUsingAccount value properly (the messagebox
> > >displays the correct value). However, it goes through and sends the
> > >mail from the originally selected account anyways. It seems like once
> > >you get to the ItemSend event, it's too late to change the account for
> > >the current message if it gets sent. However, if something interrupts
> > >the sending process (like another check for having a subject that
> > >could set cancel = TRUE and cancel the sending, or stepping through
> > >the code in debug mode), it will actually update the sending account
> > >(which I can see reflected in the message window, cause it didn't
> > >actually send).

>
> > >My question is... is there any way to update the SendUsingAccount
> > >property once you get to the ItemSend event? If not, is there an
> > >earlier place to trap this event? Is there a way to trap the event of
> > >clicking the send button and then running this code?

>
> > >Thanks in advance.

>
> > Why not set 'Cancel' yourself, set the properties you want
> > to change and resend.

>
> > You'll need some sort of flag to prevent being prompted on
> > the resend of course.

>
> > --
> > Jan Hyde (VB MVP)

>
> >https://mvp.support.microsoft.com/profile/Jan.Hyde

>
> Well, that's what I had to settle for. I now just display a message
> "Are you sure you want to send from account: ACCOUNT_NAME" OK/Cancel.
> However, I was wondering if there was a more elegant solution.
>
> As a follow-up, is there a way to know if a message is a new message
> or a reply/forward? I don't really need to perform this check if I'm
> simply replying to a message, it's more important for a new message.
>
> Thanks,
> Josh- Hide quoted text -
>
> - Show quoted text -



Reply to this post


Did you find this post helpful? Yes | No
  #6 (permalink)  
Old 23rd October 2008, 08:14 PM
Josh
Newsgroup Contributor


My Top Tip Count:

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

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


On Oct 23, 2:23*pm, "Dmitry Streblechenko" <dmi...@dimastr.com> wrote:
> Look at the ConversationIndex property - for new messages it will be 44
> characters long (22 byte for the raw PR_CONVERSATION_INDEX binary property).
>
> --
> Dmitry Streblechenko (MVP)http://www.dimastr.com/
> OutlookSpy *- Outlook, CDO
> and MAPI Developer Tool
> -"JP" <jp2...@earthlink.net> wrote in message
>
> news:2deca1b0-d765-44fe-917a-ba69b387dc58@h60g2000hsg.googlegroups.com...
> There are a couple of threads on the issue, and I can't locate them at
> the moment, but I believe the consensus was you needed to use
> Redemption to do this. I can try to locate them if you really want an
> accurate answer.
>
> Regarding your followup question, you would need to check the
> ConversationIndex to see if there is an existing message. Seehttp://www.outlookcode.com/codedetail.aspx?id=1714for code sample. As
> an alternative, you could check if Left$(MailItem.Subject, 3) = "RE:"
>
> HTH,
> JP
>
> On Oct 23, 12:50 pm, Josh <jgordon...@gmail.com> wrote:
>
> > On Oct 23, 11:09 am, "Jan Hyde (VB MVP)"

'Original Source: The Code Cage Forums http://www.thecodecage.com/forumz/outlook-macros-vba/6719-setting-send-account-visual-basic-applications.html#post22626
>
> > <StellaDrin...@REMOVE.ME.uboot.com> wrote:
> > > Josh <jgordon...@gmail.com>'s wild thoughts were released on
> > > Thu, 23 Oct 2008 07:25:02 -0700 (PDT) bearing the following
> > > fruit:

>
> > > >Like many other posters I've seen, I sometimes send mail from the
> > > >wrong account in Outlook 2007. I wanted to create a macro that when I
> > > >sent a message, would prompt me to verify the sending account, and let
> > > >me change if necessary.

>
> > > >I have the following code:
> > > >Private Sub Application_ItemSend(ByVal item As Object, Cancel As
> > > >Boolean)

>
> > > >If TypeOf item Is Outlook.MailItem Then
> > > > 'Show form that displays account list and sets
> > > >item.SendUsingAccount

>
> > > > 'To debug, verify it's using the right account:
> > > > msgbox item.SendUsingAccount
> > > >End if

>
> > > >End Sub

>
> > > >The routine works in the sense that it displays the list of accounts,
> > > >and sets the item.SendUsingAccount value properly (the messagebox
> > > >displays the correct value). However, it goes through and sends the
> > > >mail from the originally selected account anyways. It seems like once
> > > >you get to the ItemSend event, it's too late to change the account for
> > > >the current message if it gets sent. However, if something interrupts
> > > >the sending process (like another check for having a subject that
> > > >could set cancel = TRUE and cancel the sending, or stepping through
> > > >the code in debug mode), it will actually update the sending account
> > > >(which I can see reflected in the message window, cause it didn't
> > > >actually send).

>
> > > >My question is... is there any way to update the SendUsingAccount
> > > >property once you get to the ItemSend event? If not, is there an
> > > >earlier place to trap this event? Is there a way to trap the event of
> > > >clicking the send button and then running this code?

>
> > > >Thanks in advance.

>
> > > Why not set 'Cancel' yourself, set the properties you want
> > > to change and resend.

>
> > > You'll need some sort of flag to prevent being prompted on
> > > the resend of course.

>
> > > --
> > > Jan Hyde (VB MVP)

>
> > >https://mvp.support.microsoft.com/profile/Jan.Hyde

>
> > Well, that's what I had to settle for. I now just display a message
> > "Are you sure you want to send from account: ACCOUNT_NAME" OK/Cancel.
> > However, I was wondering if there was a more elegant solution.

>
> > As a follow-up, is there a way to know if a message is a new message
> > or a reply/forward? I don't really need to perform this check if I'm
> > simply replying to a message, it's more important for a new message.

>
> > Thanks,
> > Josh- Hide quoted text -

>
> > - Show quoted text -


The length=44 for ConversationIndex worked like a charm. Thanks!

I'm not familiar with redemption and a quick search didn't reveal
anything too helpful. Would you mind posting an example?

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!
  #7 (permalink)  
Old 23rd October 2008, 11:40 PM
Dmitry Streblechenko
Newsgroup Contributor


My Top Tip Count:

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

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


You don't have to use Redemption for that. MailItem exposes the
ConversationIndex property as well.

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
"Josh" <jgordon428@gmail.com> wrote in message
news:3cf8168c-d4cd-42cb-b459-85f3c0725266@26g2000hsk.googlegroups.com...
On Oct 23, 2:23 pm, "Dmitry Streblechenko" <dmi...@dimastr.com> wrote:
> Look at the ConversationIndex property - for new messages it will be 44
> characters long (22 byte for the raw PR_CONVERSATION_INDEX binary
> property).
>
> --
'Original Source: The Code Cage Forums http://www.thecodecage.com/forumz/outlook-macros-vba/6719-setting-send-account-visual-basic-applications.html#post22903
> Dmitry Streblechenko (MVP)http://www.dimastr.com/
> OutlookSpy - Outlook, CDO
> and MAPI Developer Tool
> -"JP" <jp2...@earthlink.net> wrote in message
>
> news:2deca1b0-d765-44fe-917a-ba69b387dc58@h60g2000hsg.googlegroups.com...
> There are a couple of threads on the issue, and I can't locate them at
> the moment, but I believe the consensus was you needed to use
> Redemption to do this. I can try to locate them if you really want an
> accurate answer.
>
> Regarding your followup question, you would need to check the
> ConversationIndex to see if there is an existing message.
> Seehttp://www.outlookcode.com/codedetail.aspx?id=1714for code sample. As
> an alternative, you could check if Left$(MailItem.Subject, 3) = "RE:"
>
> HTH,
> JP
>
> On Oct 23, 12:50 pm, Josh <jgordon...@gmail.com> wrote:
>
> > On Oct 23, 11:09 am, "Jan Hyde (VB MVP)"

>
> > <StellaDrin...@REMOVE.ME.uboot.com> wrote:
> > > Josh <jgordon...@gmail.com>'s wild thoughts were released on
> > > Thu, 23 Oct 2008 07:25:02 -0700 (PDT) bearing the following
> > > fruit:

>
> > > >Like many other posters I've seen, I sometimes send mail from the
> > > >wrong account in Outlook 2007. I wanted to create a macro that when I
> > > >sent a message, would prompt me to verify the sending account, and
> > > >let
> > > >me change if necessary.

>
> > > >I have the following code:
> > > >Private Sub Application_ItemSend(ByVal item As Object, Cancel As
> > > >Boolean)

>
> > > >If TypeOf item Is Outlook.MailItem Then
> > > > 'Show form that displays account list and sets
> > > >item.SendUsingAccount

>
> > > > 'To debug, verify it's using the right account:
> > > > msgbox item.SendUsingAccount
> > > >End if

>
> > > >End Sub

>
> > > >The routine works in the sense that it displays the list of accounts,
> > > >and sets the item.SendUsingAccount value properly (the messagebox
> > > >displays the correct value). However, it goes through and sends the
> > > >mail from the originally selected account anyways. It seems like once
> > > >you get to the ItemSend event, it's too late to change the account
> > > >for
> > > >the current message if it gets sent. However, if something interrupts
> > > >the sending process (like another check for having a subject that
> > > >could set cancel = TRUE and cancel the sending, or stepping through
> > > >the code in debug mode), it will actually update the sending account
> > > >(which I can see reflected in the message window, cause it didn't
> > > >actually send).

>
> > > >My question is... is there any way to update the SendUsingAccount
> > > >property once you get to the ItemSend event? If not, is there an
> > > >earlier place to trap this event? Is there a way to trap the event of
> > > >clicking the send button and then running this code?

>
> > > >Thanks in advance.

>
> > > Why not set 'Cancel' yourself, set the properties you want
> > > to change and resend.

>
> > > You'll need some sort of flag to prevent being prompted on
> > > the resend of course.

>
> > > --
> > > Jan Hyde (VB MVP)

>
> > >https://mvp.support.microsoft.com/profile/Jan.Hyde

>
> > Well, that's what I had to settle for. I now just display a message
> > "Are you sure you want to send from account: ACCOUNT_NAME" OK/Cancel.
> > However, I was wondering if there was a more elegant solution.

>
> > As a follow-up, is there a way to know if a message is a new message
> > or a reply/forward? I don't really need to perform this check if I'm
> > simply replying to a message, it's more important for a new message.

>
> > Thanks,
> > Josh- Hide quoted text -

>
> > - Show quoted text -


The length=44 for ConversationIndex worked like a charm. Thanks!

I'm not familiar with redemption and a quick search didn't reveal
anything too helpful. Would you mind posting an example?

Thanks,
Josh


Reply to this post


Did you find this post helpful? Yes | No
  #8 (permalink)  
Old 23rd October 2008, 11:58 PM
Josh
Newsgroup Contributor


My Top Tip Count:

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

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


On Oct 23, 6:14*pm, "Dmitry Streblechenko" <dmi...@dimastr.com> wrote:
> You don't have to use Redemption for that. MailItem exposes the
> ConversationIndex property as well.
>
> --
> Dmitry Streblechenko (MVP)http://www.dimastr.com/
> OutlookSpy *- Outlook, CDO
> and MAPI Developer Tool
> -"Josh" <jgordon...@gmail.com> wrote in message
>
> news:3cf8168c-d4cd-42cb-b459-85f3c0725266@26g2000hsk.googlegroups.com...
> On Oct 23, 2:23 pm, "Dmitry Streblechenko" <dmi...@dimastr.com> wrote:
>
>
>
> > Look at the ConversationIndex property - for new messages it will be 44
> > characters long (22 byte for the raw PR_CONVERSATION_INDEX binary
> > property).

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

>
> >news:2deca1b0-d765-44fe-917a-ba69b387dc58@h60g2000hsg.googlegroups.com....
> > There are a couple of threads on the issue, and I can't locate them at
> > the moment, but I believe the consensus was you needed to use
> > Redemption to do this. I can try to locate them if you really want an
> > accurate answer.

>
> > Regarding your followup question, you would need to check the
> > ConversationIndex to see if there is an existing message.
> > Seehttp://www.outlookcode.com/codedetail.aspx?id=1714forcode sample. As
> > an alternative, you could check if Left$(MailItem.Subject, 3) = "RE:"

>
> > HTH,
> > JP

>
'Original Source: The Code Cage Forums http://www.thecodecage.com/forumz/outlook-macros-vba/6719-setting-send-account-visual-basic-applications.html#post22917
> > On Oct 23, 12:50 pm, Josh <jgordon...@gmail.com> wrote:

>
> > > On Oct 23, 11:09 am, "Jan Hyde (VB MVP)"

>
> > > <StellaDrin...@REMOVE.ME.uboot.com> wrote:
> > > > Josh <jgordon...@gmail.com>'s wild thoughts were released on
> > > > Thu, 23 Oct 2008 07:25:02 -0700 (PDT) bearing the following
> > > > fruit:

>
> > > > >Like many other posters I've seen, I sometimes send mail from the
> > > > >wrong account in Outlook 2007. I wanted to create a macro that when I
> > > > >sent a message, would prompt me to verify the sending account, and
> > > > >let
> > > > >me change if necessary.

>
> > > > >I have the following code:
> > > > >Private Sub Application_ItemSend(ByVal item As Object, Cancel As
> > > > >Boolean)

>
> > > > >If TypeOf item Is Outlook.MailItem Then
> > > > > 'Show form that displays account list and sets
> > > > >item.SendUsingAccount

>
> > > > > 'To debug, verify it's using the right account:
> > > > > msgbox item.SendUsingAccount
> > > > >End if

>
> > > > >End Sub

>
> > > > >The routine works in the sense that it displays the list of accounts,
> > > > >and sets the item.SendUsingAccount value properly (the messagebox
> > > > >displays the correct value). However, it goes through and sends the
> > > > >mail from the originally selected account anyways. It seems like once
> > > > >you get to the ItemSend event, it's too late to change the account
> > > > >for
> > > > >the current message if it gets sent. However, if something interrupts
> > > > >the sending process (like another check for having a subject that
> > > > >could set cancel = TRUE and cancel the sending, or stepping through
> > > > >the code in debug mode), it will actually update the sending account
> > > > >(which I can see reflected in the message window, cause it didn't
> > > > >actually send).

>
> > > > >My question is... is there any way to update the SendUsingAccount
> > > > >property once you get to the ItemSend event? If not, is there an
> > > > >earlier place to trap this event? Is there a way to trap the eventof
> > > > >clicking the send button and then running this code?

>
> > > > >Thanks in advance.

>
> > > > Why not set 'Cancel' yourself, set the properties you want
> > > > to change and resend.

>
> > > > You'll need some sort of flag to prevent being prompted on
> > > > the resend of course.

>
> > > > --
> > > > Jan Hyde (VB MVP)

>
> > > >https://mvp.support.microsoft.com/profile/Jan.Hyde

>
> > > Well, that's what I had to settle for. I now just display a message
> > > "Are you sure you want to send from account: ACCOUNT_NAME" OK/Cancel.
> > > However, I was wondering if there was a more elegant solution.

>
> > > As a follow-up, is there a way to know if a message is a new message
> > > or a reply/forward? I don't really need to perform this check if I'm
> > > simply replying to a message, it's more important for a new message.

>
> > > Thanks,
> > > Josh- Hide quoted text -

>
> > > - Show quoted text -

>
> The length=44 for ConversationIndex worked like a charm. Thanks!
>
> I'm not familiar with redemption and a quick search didn't reveal
> anything too helpful. Would you mind posting an example?
>
> Thanks,
> Josh


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.
Reply to this post


Did you find this post helpful? Yes | No
  #9 (permalink)  
Old 23rd October 2008, 11:58 PM
Dmitry Streblechenko
Newsgroup Contributor


My Top Tip Count:

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

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


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.html#post22918
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
"Josh" <jgordon428@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.


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!
  #10 (permalink)  
Old 24th October 2008, 02:51 PM
Josh
Newsgroup Contributor


My Top Tip Count:

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

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


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.

>
'Original Source: The Code Cage Forums http://www.thecodecage.com/forumz/outlook-macros-vba/6719-setting-send-account-visual-basic-applications.html#post23401
> > --
> > 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?
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!
Reply

Bookmarks

Tags
account, sendfrom, setting, 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 02:35 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, 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