PDA

View Full Version : File Attachment from Variables



treaves04
11-26-2012, 10:38 AM
I am trying to create an email with attachments from a macro using variable. Here is what I have so Far:


Public Sub RFB()

Dim Directory As String
Dim LotNumber As String
Dim Community As String
Dim msg As Outlook.MailItem
Directory = InputBox("Please Enter Directory", _
"Directory", "Directory")
LotNumber = InputBox("Please Enter Lot Number", _
"LotNumber", "Lot Number")
Community = InputBox("Please Enter Community", _
"Community", "Community")


If Directory = "Enter your input text HERE" Or _
Directory = "" Then
End If
If LotNumber = "Enter your input text HERE" Or _
LotNumber = "" Then
End If
If Community = "Enter your input text HERE" Or _
Community = "" Then
End If

Set msg = Application.CreateItem(olMailItem)
With msg
.BCC = "someone@somewhere.com"
.Subject = "RFB - " & LotNumber & " " & Community & " Plumbing"
.Body = "Tis will be my RFB Text"
.Attachments = Directory & LotNumber & " " & Community & " - 8 - PLUMBING.pdf"
.Display
End With

End Sub



When Prompted for Directory Input I am using "P:\SyncFolder\Dropbox\Celebration Homes Communites\Belshire\109 Belshire"
Lot Number is 109
Community is BS

The full file name I am trying to attach is "109 BS - 8 - PLUMBING.pdf". If this was a constant that would be attached to every file I would simply do .attachment = P:\SyncFolder\Dropbox\Celebration Homes Communites\Belshire\109 Belshire\109 BS - 8 - PLUMBING.pdf and be done, but because this changes I want to use the named variables. Any help is appreciated. Thanks in Advance.

treaves04
11-26-2012, 11:01 AM
Nevermind, Figured it out. Lol

.Attachments.Add Directory & "/" & LotNumber & " " & Community & " - 8 - PLUMBING.pdf"