Solved

How to declare a selection of email messages

Posted on 2008-06-12
1
290 Views
Last Modified: 2013-11-22



Hi
I have written a macro that saves an open email according to certain criteria when I hit a customised toolbar button.
I wish to modify this code such that it can act on a selection of emails within the inbox - ie needs to loop through the selected items.
I am unsure how to declare the 'selected items' andhow to handle them in a loop.
If someone could please write the lines to do this, I would really appreciate it.

cheers.
my current declarations are below, where objItem is the open email.


''''''''''
Sub save_multi_msgs()

'**********************************************************************************************************
' save_multi_msgs() macro performs the following tasks:
'**********************************************************************************************************
' - is run from a customised toolbar button in the outlook main window.
' - checks to see if there is a job number in the subject
'         - if there is no job number: -  prompts the user for one
'                                      -  renames emails that are not prefixed with their job number
' - if there is no subject, renames the email jobnumber_untitled
' - checks to see if the message has been saved already (if so, tells user and asks if they still want to save, or cancel)
' - checks to see that the filepath exists (if not, creates filepath after user prompt)
'**********************************************************************************************************

    Dim myItem As Outlook.Inspector
    Dim objItem As Object
    Set myOlApp = CreateObject("Outlook.Application")
    Set myItem = myOlApp.ActiveInspector
   
    If Not TypeName(myItem) = "Nothing" Then
        Set objItem = myItem.CurrentItem
        esubject = objItem
        'Prompt the user for confirmation
        Dim strPrompt As String
        Dim JNum As String
        Dim JNum_year As String
        Dim JNum_4 As String
        'Dim MyFolder As FileSystemObject
        Dim j As Integer
        Dim FileName As String
        Dim Timed As String
        ' restructure string name to get rid of formatting
            Dim senderName As String
        Dim senderaddr As String
        ' restructure string name to get rid of formatting
         senderaddr = objItem.SenderEmailAddress
         senderName = objItem.senderName
             Dim k As Integer
    Dim k1 As Integer
    Dim posn1(10) As String
    Dim Filepath1_folder(10) As String

' Executes code to save msg here.
' objItem is the open email.


del: objItem.Delete 'this line deletes the email from the inbox
fin:
End Sub
0
Comment
Question by:kafrin_1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 

Accepted Solution

by:
kafrin_1 earned 0 total points
ID: 21774634
Got it:

added Dim myOlExp As Outlook.Explorer
Dim myOlSel As Outlook.Selection

   Set myOlExp = myOlApp.ActiveExplorer
Set myOlSel = myOlExp.Selection
Dim iSel As Long
iSel = myOlSel.Count
'for all items do...
For Each myItem In myOlSel

commented out  'Dim myItem As Outlook.Inspector
0

Featured Post

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Following basic email etiquette rules will help you write a professional email and achieve a good, lasting impression with your contacts.
Many people use more than one email account and so it becomes difficult for them to manage them when they use separate accounts,  so, in this article, I have shared an easy way to add Other Mail Accounts in your Google Inbox. It helps to combine all…
Many of my clients call in with monstrous Gmail overloading issues with Outlook. A quick tip is to turn off the All Mail and Important folders from synching. Here is a quick video I made to show you how to turn off these and other folders in Gmail s…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question