A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Add-ins for Outlook
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

COM addin from VB.NET 2003



 
 
Thread Tools Search this Thread Display Modes
  #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
  #2  
Old April 24th 06, 02:25 PM posted to microsoft.public.outlook.program_addins
Rog
external usenet poster
 
Posts: 62
Default COM addin from VB.NET 2003

this is in C#: but you would use the Explorer object,
this._outlookApplicationObject.ActiveExplorer().Se lection;
This will give you access to the items that are currently selected in
the active explorer.
Rog


Russ Green wrote:
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



 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I get rid of an Outlook 2003 addin error message? Glynn Brooks Outlook - Installation 0 March 29th 06 07:25 PM
program new toolbar in outlook with VB.NET 2003 Oskar Vaia Add-ins for Outlook 2 March 20th 06 04:34 PM
.NET AddIn Question UserControl in Folder homepage David Ing Outlook and VBA 8 March 4th 06 01:24 PM
Issues with .NET addin, web-services, and shimming Sergey Anchipolevsky Add-ins for Outlook 0 February 22nd 06 01:26 PM
best way to support outlook 2000, 2002, and 2003 and .NET Josh Einstein Add-ins for Outlook 1 January 8th 06 08:30 AM


All times are GMT +1. The time now is 03:04 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.