View Single Post
  #1  
Old April 23rd 06, 08:15 PM posted to microsoft.public.outlook.program_addins
Russ Green
external usenet poster
 
Posts: 1
Default COM addin from VB.NET 2003

I've successfully built my first Outlook addin using VB.NET 2003.

What I want to achieve is an addin that help file emails. When I message is sent a msgbox pops up asking the user if the email should be filed or not.

I will implement a similar msgbox for when a new mail is read.

However, in the short term I want to get something else working. My addin creates a toolbar button on standard toolbar. At the moment when a user clicks this button a msgbox appears telling them they have clicked it. What I want to to though is determine if a mail item is selected in a mailbox, if it is then I want to save the mail item and attachments something like this:

Dim myMail As Outlook.MailItem

' Save new Data
If MsgBox("Would you like to file the selected item?" & vbCrLf & myMail.Subject.ToString & _
vbCrLf & myMail.SentOn.ToString, MsgBoxStyle.YesNo, "Mail Manager") = MsgBoxResult.Cancel Then
Exit Sub
Else
' Open the save form in Dialog Mode
Dim frm As New frmMain

With frm
.ShowDialog()
.Dispose()

'save the message....
If frm.DialogResult = DialogResult.OK Then

Dim sSaveMsg As String
sSaveMsg = frm.sSavePath & "\" & myMail.To.ToString & "_" & RemoveIllegalCharacters(myMail.Subject.ToString) & ".msg"

With myMail
Dim i, iAttCount As Integer
iAttCount = .Attachments.Count()

For i = 1 To iAttCount
If FileExists(frm.sSavePath & "\" & .Attachments.Item(i).FileName) = True Then
.Attachments.Item(i).SaveAsFile(frm.sSavePath & "\" & ..Attachments.Item(i).FileName & " [ADDED - " & MonthShort() & "]")
Else
.Attachments.Item(i).SaveAsFile(frm.sSavePath & "\" & ..Attachments.Item(i).FileName)
End If
Next

For i = 1 To iAttCount
.Attachments.Remove(i)
Next

.SaveAs(sSaveMsg)
End With

End With
End If

How do I first detect if a mail item is selected?

Project source attached....

TIA

Russ Green



Ads