vijay.vizzu
Member
Dear All
I want to skip a file selection, when the file name starts with QP. Below is my code, The problem is that file names which are starts with after Q, then the files not selected, and code exit, So i need a code, it need to send all files except the file name starts with QP in that folder.
[pre]
[/pre]
I want to skip a file selection, when the file name starts with QP. Below is my code, The problem is that file names which are starts with after Q, then the files not selected, and code exit, So i need a code, it need to send all files except the file name starts with QP in that folder.
[pre]
Code:
Public Sub SendMail()
Dim fso As New FileSystemObject
Dim myFolder As Folder
Dim myFile As File
Dim OutApp As New Outlook.Application
Dim myMail As Outlook.MailItem
Dim Email As String
Set myFolder = fso.GetFolder("W:Quote Pendency")
With Application
.ScreenUpdating = False
.EnableEvents = False
End With
For Each myFile In myFolder.Files
Debug.Print myFile.Name
Select Case Left(myFile.Name, 3)
Case "HAR"
Email = "HChaurasia@yamaha-motor-india.com"
Case "KAP"
Email = "RKapoor@yamaha-motor-india.com"
Case "NIK"
Email = "NSrivastava@yamaha-motor-india.com"
Case "NIT"
Email = "NDua@yamaha-motor-india.com"
Case "PPS"
Email = "PPSingh@yamaha-motor-india.com"
Case "RAJ"
Email = "RajdevSRawat@yamaha-motor-india.com"
Case "RAK"
Email = "RakeshY@yamaha-motor-india.com"
Case Else
Exit For
End Select
Debug.Print Email
Set myMail = OutApp.CreateItem(olMailItem)
With myMail
.To = Email
.CC = "RRArora@yamaha-motor-india.com;TKuranaga@yamaha-motor-india.com"
.Subject = "Quote Pendency Summary " & UCase(Format(Now, "dd-mmm-yy"))
.Body = "Dear Sir" & vbCrLf & vbCrLf & "Please find attached Quote Pendency for your reference"
.Attachments.Add (myFile)
.Send
End With
Next
With Application
.ScreenUpdating = True
.EnableEvents = True
End With
End Sub