Prompt Subject

josros60

Well-known Member
Joined
Jun 27, 2010
Messages
529
Hi,

found this code in the web and changed the path and subject, is there anyway to modify it that it prompts for the subject to type?

code:

VBA Code:
Sub GetAttachments()
    
    Set OlApp = CreateObject("Outlook.Application")
     
    Dim olNs As Outlook.Namespace
    Dim Fldr As Outlook.MAPIFolder
    Dim olMail As Variant
    Dim fsSaveFolder, sSavePathFS, sir() As String
    Dim msg As Outlook.MailItem
    Dim olAttach As Attachment, olItem As MailItem
       
    Set OlApp = New Outlook.Application
    Set olNs = OlApp.GetNamespace("MAPI")
    Set Fldr = olNs.GetDefaultFolder(olFolderInbox)
    Set myTasks = Fldr.items
    
    fsSaveFolder = "C:\Attachments\New\"
    
    Set olMail = myTasks.Find([B][COLOR=rgb(226, 80, 65)]"[Subject] = ""Long Distance""")[/COLOR][/B]
    ThisEmails = myTasks.Count

    If Not (olMail Is Nothing) Then
        ThisAttachments = olMail.Attachments.Count
        ThisEmails = myTasks.Count
        ThisFileName = olMail.Attachments(1).Filename

        While olMail <> "Nothing"
            'Save attachment to drive
            olMail.Attachments(1).SaveAsFile fsSaveFolder & olMail.Attachments(1).Filename
            
            'Move email to Outlook folder
            Set Fldr = Outlook.Session.Folders("Holloway,James").Folders("Conference")
            olMail.Move Fldr
            Set olMail = myTasks.FindNext
            If olMail Is Nothing Then
                Exit Sub
            End If
        Wend
    End If

End Sub

Thank you
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK

ranman256

Well-known Member
Joined
Jun 17, 2014
Messages
1,977
Code:
While olMail <> "Nothing"           

vSubj = inputbox("Enter Subject","Add Subject")

with olMail
  .Subject = vSubj
  .To = "cXavier@aol.com"

        'Save attachment to drive          
  .Attachments(1).SaveAsFile fsSaveFolder & olMail.Attachments(1).Filename
end with
 

josros60

Well-known Member
Joined
Jun 27, 2010
Messages
529
thank you.

Tried didn't work no sure if put your code in the right spot, would you mind inserting your suggestion in the complete code.
 

Watch MrExcel Video

Forum statistics

Threads
1,129,539
Messages
5,636,903
Members
416,949
Latest member
propertyscout

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top