Option Explicit
' Subroutine Creates an email, addresses it, attaches file, and sends it.
Sub AttachmentEmail()
Dim oNewMail As Object
Dim oAttachments As Object
Dim sDirectory As String
Dim sFileToSend As String
Dim sMsgBody As String
'Path to the sDirectory where the file is located
'You will have to put in a valid path (make sure you include the quotes around the path)
sDirectory = "C:\Documents and Settings\<user name>\My Documents\"
'Name of the file you want to attach
'sFileToSend = "<name of the file you want to send>"
' Text that will go in the message body
sMsgBody = "This message was generated with Visual Basic for Applications"
' Concatenate a carriage return/line feed to the message body
sMsgBody = sMsgBody & vbCrLf
'creates a new email
Set oNewMail = ThisOutlookSession.CreateItem(olMailItem)
'Fill in the subject field
oNewMail.Subject = "Whatever your subject is"
' Fill the 'To', 'CC' and 'BCC' fields
oNewMail.To = "somebody@somesystems.com"
oNewMail.CC = "anybody@anysystems.com"
oNewMail.BCC = "nobody@nowhere.com"
' Insert the message in the body
oNewMail.Body = sMsgBody
' Attach file to email
Set oAttachments = oNewMail.Attachments
'This concatinates the sDirectory with the file name
oAttachments.Add sDirectory & sFileToSend
' Makes the new email visible
oNewMail.Display
' Remove the quote and oNewMail.Send will send the email
' oNewMail.Send
' Clean up
Set oAttachments = Nothing
Set oNewMail = Nothing
End Sub