Prompt Subject

josros60

Well-known Member
Joined
Jun 27, 2010
Messages
780
Office Version
  1. 365
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

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
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
 
Upvote 0
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.
 
Upvote 0

Forum statistics

Threads
1,214,932
Messages
6,122,334
Members
449,077
Latest member
Jocksteriom

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
Back
Top