RagingBokky
New Member
- Joined
- May 27, 2017
- Messages
- 12
Hi all,
I am trying to create an email where attachment has a some generic folder path but with cell value changes the final folder location
example
"\\server\nextfolder\nextfolder" & finalfoldername
add all files in folder as attachment in email
but I want my finalfoldername to be a converted cell from alphanumeric to just numeric so that the final file path would be
Cell A3 = CO258963
"\\server\nextfolder\nextfolder" & 258963
so that it would be taking all files from \\server\nextfolder\nextfolder\258963
I am trying to create an email where attachment has a some generic folder path but with cell value changes the final folder location
example
"\\server\nextfolder\nextfolder" & finalfoldername
add all files in folder as attachment in email
but I want my finalfoldername to be a converted cell from alphanumeric to just numeric so that the final file path would be
Cell A3 = CO258963
"\\server\nextfolder\nextfolder" & 258963
so that it would be taking all files from \\server\nextfolder\nextfolder\258963
Code:
Sub Email
Dim OutApp As Object Dim OutMail As Object
Dim strbody As String
Dim StrPath As String
Dim strFilename As String
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
StrPath = "\\server\folder\folder" & Val(Range("A3"))
i = 0
strbody = "[COLOR=#4D4D4D][FONT=Arial]Hi,"
On Error Resume Next
With OutMail
.to = ""
.CC = ""
.BCC = ""
.Subject = "This is the Subject line"
.HTMLBody = strbody
'You can add a file like this
Do While Len(strFilename) > 0
strFilename = Dir(StrPath & "*.*")
.Attachments.Add StrPath & strFilename
i = i + 1
If i > 15 Then Exit Do
Loop
.Display 'or use .Send
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
End Sub[/FONT][/COLOR]