Attachments to New email item

Status
Not open for further replies.

suhasjose

Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server
Can someone please help me out with this? I have almost 150 pdf files in a folder and i want to email them to a common email address based on the file names. For example; There are files names as - 1000,1000#1,1000#2,2000,3000,41000,41000#1 - Here I need to send every files with same name before "#" in one email. In this example files -1000,1000#1,1000#2 -should go in one email, 2000 should go in another email, 3000 should go in another email and 41000,41000#1 should go in another email. I have been able to send each file in th efolder in seperate emails, but I couldn't figure out how to attach files in the above said manner.. I am trying to automate outlook to do this task.

Thanks in advance for your valuable advices!
 
Outlook version
Outlook 2007
Email Account
Exchange Server
Sub AddFiles()
Dim StrFolder, StrFile, StrFiles(200), StrSearch As String
Dim i, j As Integer
Dim myMailItem As MailItem
'Select FOLDER and save all file name in an array
StrFolder = "C:\New Folder" ' CHANGE THE FOLDER
StrFile = Dir(StrFolder & "\*")
Do While Len(StrFile) > 0
i = i + 1
StrFiles(i) = StrFile
StrFile = Dir
Loop
'Loop through the array, upon finding a filename with 4 characters, loop through the aray again and find similar files
For j = 1 To i
If Len(StrFiles(j)) = 8 Then ' eg 1000.pdf - 8 characters
Set myMailItem = Application.CreateItem(olMailItem)
StrSearch = Left(StrFiles(j), 4) ' eg 1000 - first 4 characters
For k = 1 To i
If Left(StrFiles(k), 4) = StrSearch Then
MsgBox StrFiles(k)
myMailItem.Attachments.Add StrFolder & "\" & StrFiles(k)
End If
Next
myMailItem.To = "ADD RECIPIENTS"
myMailItem.Display ' Change to .send after testing
End If
Next

End Sub
 
Status
Not open for further replies.
Thread starter Similar threads Forum Replies Date
T Outlook converts sent email to txt attachments when sync Using Outlook 0
Dan_W Nested email attachments Outlook VBA and Custom Forms 4
M Print email and, attachments sent in hyperlinks in the email Outlook VBA and Custom Forms 2
W Save and rename outlook email attachments to include domain name & date received Outlook VBA and Custom Forms 4
G Download pdf attachments only if email subject has one of words Outlook VBA and Custom Forms 8
I Forwarding attachments in email received Outlook VBA and Custom Forms 3
A Outlook - Send New 20 Attachments through Email Using Outlook 4
C Auto save outlook attachments when email is received Outlook VBA and Custom Forms 1
C Rule To Save attachments on receipt of email Outlook VBA and Custom Forms 2
Diane Poremsky Add Attachments and Set Email Fields During a Mail Merge New Slipstick.com Articles 0
G VBA Copy draft email to a new email - attachments not copided Using Outlook 7
Diane Poremsky Add attachments and set email fields during a mail merge to email New Slipstick.com Articles 0
M VBA code to save email attachments (PDF) as email subject line Outlook VBA and Custom Forms 1
T Saving Outlook 2010 email with attachments but read the email without Outlook Using Outlook 2
L Auto printing unread email + attachments in Inbox - Outlook 2010 - (New user) Using Outlook 1
C Visual Basic auto create task from email including attachments Using Outlook 9
G archive attribute for email attachments Using Outlook 2
H outlook email merging with attachments Using Outlook 4
R BCM: Email attachments are not shown BCM (Business Contact Manager) 4
M Outlook 2010 and how to get attachments listed when creating a new email? Using Outlook 1
B Web-based email attachments won't open in Office 2010 Using Outlook 5
M Change default program for opening email attachments. Using Outlook 1
P Outlook 2007 won't send email with attachments Using Outlook 2
B Outlook 2011 email attachments Using Outlook 1
A When forwarding attachments, the email address of recipient is lost Using Outlook 2
A outlook keeps files sent as attachments locked after email has been sent... Using Outlook 3
R Email attachments in Outlook 2007 Using Outlook 1
P Can't open attachments in body of email in Outlook 2010. Using Outlook 4
V Outlook 2010 - attachments with mail merge email Using Outlook 4
C MS Outlook 2007 - UTF-8 characters are not properly shown in email attachments Using Outlook 1
C Email attachments will not open in outlook nor will they open if I save and try to open. They are sh Using Outlook 1
G opening attachments from an email closes the program and restarts outlook 90% of the time Using Outlook 2
M RECENTLY UPGRADED FROM HOME & BUSINESS to OFFICE PRO - CANNOT OPEN ATTACHMENTS DIRECTLY FROM EMAIL Using Outlook 1
B Recipient is Missing email attachments Using Outlook 2
P Cannot open .jpg from email attachments Using Outlook 6
T "The Operation Failed" When opening file attachments on an email. Using Outlook 1
K Forwarding an email with Attachments Using Outlook 3
N Cannot hear audio in email attachments on outlook 2010 Using Outlook 3
J Exchange 2010 - Email attachments sending to multiple userts Exchange Server Administration 3
G Re: Outlook 2007 email attachments Using Outlook 3
R OWA 2010 SP1 Email sent to OWA 2003 attachments missing Exchange Server Administration 20
C Attachments come across as win.dat files to receiver. Attachments end up in the body of the email, not at the top as an attachment. How can this be Using Outlook 1
B OE6 Opens *.eml attachments as Outlook 2010 Email even though OE is default. Using Outlook 2
L Changing where Outlook 2010 automatically saves email attachments Using Outlook 1
C Tried to send an email with attachments that were too large and not it is 'stuck' in my outbox. Using Outlook 1
C Saving email including attachments Using Outlook 4
5 Automatically print email attachments Using Outlook 7
R Auto Reply with Original Email and any attachments Outlook VBA and Custom Forms 1
K Mail Merge to email with attachments Outlook VBA and Custom Forms 8
H Storing an email along with its attachments? Outlook VBA and Custom Forms 1
Similar threads


















































Top