Home All Groups Group Topic Archive Search About
Author
23 Sep 2005 12:54 PM
Sentinel
I would like to ad a toolbar into outlook or add two buttons onto
existing toolbar in outlook.

when clicked on a button, the program must pull the text from the
selected mail (or mail editor) and do something with it, and then
display it (or return it to mail editor)


how can i do this?

vb6

--
Will work for bandwidth!

Author
23 Sep 2005 2:04 PM
Matt Williamson
You want to do ALL of this programatically or can you add the toolbar and
buttons manually and just use the code to do your required tasks?

Here is a bit of code that will take the currently selected emails and grab
the text from them into a string array


Sub GetMessageText()

Dim myItems As Selection
Dim myItem As MailItem
Dim i As Long
Dim aryMSG() As String

Set myItems = ActiveExplorer.Selection 'Gets selection

For Each myItem In myItems 'Loops through selected items
  ReDim Preserve aryMSG(myItems.Count)
  i = i + 1
  aryMSG(i - 1) = myItem.Body
  Debug.Print aryMSG(i - 1)
Next myItem

Set myItem = Nothing
Set myItems = Nothing

End Sub

HTH

Matt


Show quoteHide quote
"Sentinel" <supp***@elma.hr> wrote in message
news:xn0e7l77oew4d5001@news.t-com.hr...
>I would like to ad a toolbar into outlook or add two buttons onto
> existing toolbar in outlook.
>
> when clicked on a button, the program must pull the text from the
> selected mail (or mail editor) and do something with it, and then
> display it (or return it to mail editor)
>
>
> how can i do this?
>
> vb6
>
> --
> Will work for bandwidth!
Author
23 Sep 2005 2:06 PM
Bob Butler
"Sentinel" <supp***@elma.hr> wrote in message
news:xn0e7l77oew4d5001@news.t-com.hr
> I would like to ad a toolbar into outlook or add two buttons onto
> existing toolbar in outlook.
>
> when clicked on a button, the program must pull the text from the
> selected mail (or mail editor) and do something with it, and then
> display it (or return it to mail editor)

See if this gets you started:

Option Explicit
Private WithEvents moOutlook As Outlook.Application
Private WithEvents moMAPI As Outlook.NameSpace
Private WithEvents moMyButton As Office.CommandBarButton
Private moCB As Office.CommandBar

Private Sub Form_Load()
ConnectOutlook
End Sub

Private Sub ConnectOutlook(Optional ByVal Retry As Boolean)
On Error Resume Next
Set moOutlook = GetObject(, "Outlook.Application")
Set moMAPI = moOutlook.GetNamespace("MAPI")
moMAPI.Logon showdialog:=False, newsession:=False
Set moCB = moOutlook.ActiveExplorer.CommandBars.Add("MyCB", msoBarTop, ,
True)
moCB.Visible = True
Set moMyButton = moCB.Controls.Add(msoControlButton, , , , True)
moMyButton.Caption = "My Button"
If (moOutlook Is Nothing) Or (moCB Is Nothing) Or (moMyButton Is Nothing)
Then
  DisconnectOutlook
  MsgBox "Connection failed"
End If
End Sub

Private Sub DisconnectOutlook()
On Error Resume Next
moMyButton.Delete
Set moMyButton = Nothing
moCB.Delete
Set moCB = Nothing
moMAPI.Logoff
Set moMAPI = Nothing
Set moOutlook = Nothing
End Sub

Private Sub Form_Unload(Cancel As Integer)
DisconnectOutlook
End Sub

Private Sub moMyButton_Click(ByVal Ctrl As Office.CommandBarButton, _
        CancelDefault As Boolean)
Dim oItem As Object
For Each oItem In moOutlook.ActiveExplorer.Selection
  MsgBox TypeName(oItem)
Next
End Sub

Private Sub moOutlook_Quit()
DisconnectOutlook
MsgBox "disconnected"
End Sub




--
Reply to the group so all can participate
VB.Net: "Fool me once..."
Author
26 Sep 2005 9:13 AM
Sentinel
Sentinel 23.09.2005 14:54:09 <xn0e7l77oew4d5***@news.t-com.hr>
supp***@elma.hr microsoft.public.vb.general.discussion Sentinel

> I would like to ad a toolbar into outlook or add two buttons onto
> existing toolbar in outlook.
>
> when clicked on a button, the program must pull the text from the
> selected mail (or mail editor) and do something with it, and then
> display it (or return it to mail editor)
>
>
> how can i do this?
>
> vb6

thanks.

--
Will work for bandwidth!