attaching files to email

S

Simon

I have been attaching files to emails which works great but i would
prefer it to rename the file the customer order number

for examples the file added to the email is rptOrder.pdf but i would
like it to include thier order number like Order_13424.pdf


Can this be done

Also is there a way to add more attachement to the email like files
that are sorted on the pc hard drive C:\Documents\Terms.pdf

Thanks
 
B

banem2

I have been attaching files to emails which works great but i would
prefer it to rename the file the customer order number

for examples the file added to the email is rptOrder.pdf  but i would
like it to include thier order number like Order_13424.pdf

Can this be done

Also is there a way to add more attachement to the email like files
that are sorted on the pc hard drive C:\Documents\Terms.pdf

Thanks

Use

Name "oldfile" As "newfile"

to rename file; actually:

Name "c:\rptOrder.pdf" As "c:\Order_" & CustomerOrderNumber & ".pdf"

Adjust the path first.

To attach more files using Outlook use (part of the code only):

Dim strAttachment(1 to 10) 'up to 10 attachments
Dim objApp As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookAttach As Outlook.Attachment
With objOutlookMsg
Do While strAttachment(x) <> ""
Set objOutlookAttach = .Attachments.Add(strAttachment(x))
x = x + 1
Loop
End With

Regards,
Branislav Mihaljev
Microsoft Access MVP
 
B

banem2

I have been attaching files to emails which works great but i would
prefer it to rename the file the customer order number

for examples the file added to the email is rptOrder.pdf  but i would
like it to include thier order number like Order_13424.pdf

Can this be done

Also is there a way to add more attachement to the email like files
that are sorted on the pc hard drive C:\Documents\Terms.pdf

Thanks

Hm, looks like I forgot to answer last question. I just wrote a
function which will read file names in folder (up to 100 files).

Call it with

fReadFiles("c:\", "pdf")

for .PDF files or without file type parameter to get all the file
names:

fReadFiles("c:\")

before you run code to attach files to Outlook message.

Change the path to desired folder.

Public strFileName(1 To 100) As String

Function fReadFiles(strFolderName As String, _
Optional strFileType As String)

Dim strFileNameLoc As String, i As Integer
For i = 1 To 100
strFileName(i) = ""
Next
If Len(strFolderName) = 0 Then Exit Function
If Right(strFolderName, 1) <> "\" Then
strFolderName = strFolderName & "\"
End If
If Len(strFileType) = 0 Then
strFileNameLoc = Dir(strFolderName & "\*.*")
Else
strFileNameLoc = Dir(strFolderName & "\*." & strFileType)
End If
i = 1
Do While strFileNameLoc <> ""
If (GetAttr(strFolderName & "\" & strFileNameLoc) And vbDirectory)
<> _
vbDirectory Then
If strFileNameLoc <> "." Or strFileNameLoc <> ".." Then
strFileName(i) = strFolderName & strFileNameLoc
i = i + 1
End If
End If
strFileNameLoc = Dir
Loop

End Function

-----

Now you can attach all the PDF files in selected folder to Outlook
message using solution from my previous post. There is no error
handling.

Regards,
Branislav
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top