Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Outlook / Programming VBA / May 2006

Tip: Looking for answers? Try searching our database.

Cannot find Accounts Control ID:=31224

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
n777krish@gmail.com - 07 May 2006 22:40 GMT
I am using code copied at end of this message to try and change the
"send
from" account.  Code is based on Sue Mosher's Book example. For some
reason
the Send From address does not change.  The problem appears to be that
the Send From Account does not get changed even throug the line is run.
I have tried this code on Outlook 2000/ 2002

Any help will be greatly appreciated.
Thanks in advance
Neil

Option Explicit
Const ACCT_TO_USE = "Someaccount"

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As
Boolean)
   'How can we get the name of the account that will be used to send

   Dim objInsp As Outlook.Inspector
   Dim colCB As Office.CommandBars
   Dim objCBAccounts As Office.CommandBarPopup
   Dim objCBB As Office.CommandBarButton
   Dim blnAccountFound As Boolean

   Set objInsp = Item.GetInspector
   Set colCB = objInsp.CommandBars
   Set objCBAccounts = colCB.FindControl(ID:=31224)
   Set objCBB = objCBAccounts.Controls.Item(1)

   If Not objCBB Is Nothing Then
       If objCBB.Caption <> ACCT_TO_USE Then
           Set objCBB = Nothing
           For Each objCBB In objCBAccounts.Controls
               If InStr(1, objCBB.Caption, ACCT_TO_USE, vbTextCompare)
> 0
Then
                   blnAccountFound = True
                   Err.Clear
                   objCBB.Execute

                   Exit For
               End If
           Next
       End If

       If blnAccountFound = False Or Err.Number <> 0 Then
           Cancel = True
       End If
   End If

   Set objInsp = Nothing
   Set colCB = Nothing
   Set objCBAccounts = Nothing
   Set objCBB = Nothing

End Sub
Sue Mosher [MVP-Outlook] - 16 May 2006 15:29 GMT
That technique won't work if Word is the email editor. See
http://www.outlookcode.com/codedetail.aspx?id=889 for various other approaches .

Signature

Sue Mosher, Outlook MVP
  Author of Configuring Microsoft Outlook 2003
    http://www.turtleflock.com/olconfig/index.htm
  and Microsoft Outlook Programming - Jumpstart for
    Administrators, Power Users, and Developers
    http://www.outlookcode.com/jumpstart.aspx
 

>I am using code copied at end of this message to try and change the
> "send
[quoted text clipped - 53 lines]
>
> End Sub
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.