Prompt and save sent emails when itemadd to Sent Items

Add-in Express™ Support Service
That's what is more important than anything else

Prompt and save sent emails when itemadd to Sent Items
 
Paul Forrester




Posts: 10
Joined: 2017-08-11
Hi,

I have written an email saving tool which users can use to save selected emails in their inbox.

I am now adding more functionality to prompt the user if they wish to save a sent item, I have been looking at ItemAdd for the sent items but struggling a bit. Can anyone assist please?


Thank you
Posted 11 Aug, 2017 04:20:18 Top
Dmitry Kostochko


Add-in Express team


Posts: 2731
Joined: 2004-04-05
Hi Paul,

Please have a look at the http://" target="_blank">MailItem.SaveSentMessageFolder property. Probably you can use it instead of checking the Sent Items folder.
Posted 11 Aug, 2017 05:53:04 Top
Paul Forrester




Posts: 10
Joined: 2017-08-11
Thank you, I will look at this now.
Posted 11 Aug, 2017 06:03:08 Top
Paul Forrester




Posts: 10
Joined: 2017-08-11
Hi Dmitry,

I am struggling with this one. My intention is to save the email once it is in the Sentitems folder.

The user sends an email as normal and is then prompted to select a folder path from a combo list once the email hits this folder.

That way I know it has been sent.

Is there any code to illustrate this?



Thank you
Posted 11 Aug, 2017 06:38:26 Top
Dmitry Kostochko


Add-in Express team


Posts: 2731
Joined: 2004-04-05
Hi Paul,

To handle the ItemAdd event you need to use the ADXOutlookItemsEvents class. Please read the "Step #13 Handling Events of the Outlook Items Object" chapter (page 79) of the Add-in Express Developer Guide, there is code sample there.
Posted 11 Aug, 2017 07:13:33 Top
Paul Forrester




Posts: 10
Joined: 2017-08-11
Thank you, function is working now.
Posted 11 Aug, 2017 08:13:20 Top
Dmitry Kostochko


Add-in Express team


Posts: 2731
Joined: 2004-04-05
Hi Paul,

You are welcome!
Posted 11 Aug, 2017 08:47:52 Top
Paul Forrester




Posts: 10
Joined: 2017-08-11
Apologies, I am stuck trying to figure out how to pass the triggered ItemAdd mail Item into a Form, where I can select the appropriate folder location and save the email.

The code for the selection of an email and then saving works fine:


Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        Try
            Dim myOlApp As New Outlook.Application
            Dim myOlExp As Outlook.Explorer
            Dim myOlSel As Outlook.Selection
            Dim myPath As String
            Dim x As Integer
            Dim RuleSource As String
            Dim sName As String
            Dim dtDate As String
            Dim strCats As String
            Dim eSend As String

            RuleSource = "Combo"

            

            myOlExp = myOlApp.ActiveExplorer
            myOlSel = myOlExp.Selection
            If myOlSel.Count = 0 Then
                MsgBox("You have not selected any emails")
            Else
                If Len(TextBox1.Text) = 0 And Len(ComboBox1.Text) = 0 Then
                    MsgBox("You have not selected a save location")
                Else
                    If Len(TextBox1.Text) = 0 Then
                        myPath = ComboBox1.Text
                        RuleSource = "Combo"
                    Else
                        myPath = TextBox1.Text
                        RuleSource = "Text"
                    End If


How do I reference the recently added 'sent item' in the saving code?


Thanks again.
Posted 11 Aug, 2017 10:18:28 Top
Dmitry Kostochko


Add-in Express team


Posts: 2731
Joined: 2004-04-05
Hi Paul,

You can pass Item as an argument to some method that will create your form, etc. For example:


Public Overrides Sub ItemAdd(ByVal Item As Object)

  CreateMyFormAndShow(Item)

  ' or
  Dim frm as MyForm
  frm = New MyForm()
  frm.MyInitialize(Item)
  frm.ShowDialog()
  frm.Dispose()

End Sub
Posted 11 Aug, 2017 10:44:53 Top
Paul Forrester




Posts: 10
Joined: 2017-08-11
Yet again, thank you. I should be fine now :-)
Posted 11 Aug, 2017 11:08:30 Top