Outlook add-in

H

Himselff

Hi guys,

Im developing a lil add-in that is goiing to allow the user by a button
click to auto print PDF doc which are attach to hes emails, i think the
things is to simple cause its not working at all, hope u guys can gimme a
hand , heres the code,

Public Sub OnStartupComplete(ByRef custom As System.Array) Implements
Extensibility.IDTExtensibility2.OnStartupComplete

On Error Resume Next

Dim oCommandBars As CommandBars

Dim oStandardBar As CommandBar

' Set up a custom button on the "Standard" command bar.

oCommandBars = applicationObject.CommandBars

If oCommandBars Is Nothing Then

' Outlook has the CommandBars collection on the Explorer object.

oCommandBars = applicationObject.ActiveExplorer.CommandBars

End If

oStandardBar = oCommandBars.Item("Standard")

If oStandardBar Is Nothing Then

' Access names its main toolbar Database.

oStandardBar = oCommandBars.Item("Database")

End If

' In case the button was not deleted, use the exiting one.

MyButton = oStandardBar.Controls.Item("Polyform Auto-print")

If MyButton Is Nothing Then

MyButton = oStandardBar.Controls.Add(1)

With MyButton

.Caption = "Polyform Auto-Print"

.Style = MsoButtonStyle.msoButtonCaption

' The following items are optional, but recommended.

' The Tag property lets you quickly find the control

' and helps MSO keep track of it when more than

' one application window is visible. The property is required

' by some Office applications and should be provided.

.Tag = "Polyform Auto-print"

' The OnAction property is optional but recommended.

' It should be set to the ProgID of the add-in, so that if

' the add-in is not loaded when a user clicks the button,

' MSO loads the add-in automatically and then raises

' the Click event for the add-in to handle.

.OnAction = "!<MyCOMAddin.Connect>"

.Visible = True

End With

End If

MsgBox("button load")

oStandardBar = Nothing

oCommandBars = Nothing

End Sub

Private Sub MyButton_Click(ByVal Ctrl As
Microsoft.Office.Core.CommandBarButton, ByRef CancelDefault As Boolean)
Handles MyButton.Click

Dim myOutlook As Outlook.Application = New Outlook.Application

Dim myNs 'As Outlook.NameSpace

Dim myFolder As Outlook.MAPIFolder

Dim myMessage As Object

Dim pathName As String

Dim myAttachement As Outlook.Attachment

Dim items As Outlook.Items

myNs = myOutlook.GetNamespace("MAPI")

myFolder = myNs.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox)

items = myFolder.Items

MsgBox("variable setter")

Dim i As Integer

Dim oMsg As Outlook.MailItem

Dim attch, monExt, maLongueur

For i = 1 To items.Count

oMsg = items.Item(i)

If oMsg.Attachments.Count > 0 Then

oMsg.Attachments.Item(i).SaveAsFile("c:\travail\temp\attachements\" &
oMsg.Attachments.Item(i).FileName)

maLongueur = Len(oMsg.Attachments.Item(i).FileName)

monExt = Mid(oMsg.Attachments.Item(i).FileName, maLongueur - 2, 3)

MsgBox("Entre dans le case " & maLongueur & " " & monExt)

Select Case monExt

Case "pdf"

Process.Start("c:\Program Files\Adobe\Acrobat 6.0\Reader\AcroRd32.exe",
"/p/h ""C:\travail\temp\attachements\" & oMsg.Attachments.Item(i).FileName &
"")

End Select

MsgBox(oMsg.Attachments.Item(i).FileName)

End If

Next i

myOutlook = Nothing

myNs = Nothing

myFolder = Nothing

oMsg = Nothing

items = Nothing

MsgBox("Tout les commandes ont été imprimé correctement !")

End Sub

As u can see its very basic, add button, and when button is clicked and
thats it , ive generate all this trough add-in wizard of visual studio dot
net !

thanks in advance for the help !

Him
 
H

Himselff

Ok i think i didnt been clear on my question,

First i made a lil add-in that from a button i add to Outlook 2k bar, that
trigger a litle code that goes trough each email in the client inbox and
print attachement if they are PDF, super easy and super simple,

The problem is that im running the add-in trough debug mode and it work,
once install on the client nothing work, i go back on my station to try it
again and nothing work anymore...

Is there any known issue about add-in programming ? or is it something whit
the coding i didnt do right,

im very lost !

Thanks in advance !

Him
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top