• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Help attaching file to email (partially working)

BigD

Member
The code that I am posing below sends the email, but it does not attach the Excel file. Is this a quick fix? Any help is greatly appreciated.

Code:
Private Sub CommandButton1_Click()

Dim SabineID As String
Dim strpath As String
Dim strtask As String


Application.ScreenUpdating = False
ActiveSheet.Select
ActiveSheet.Copy

strpath = Range("AA1").Value
SabineID = Range("V18").Value
strtask = Range("A18").Value
strarea = Range("b18").Value
stremail = Range("j2").Value

ActiveSheet.SaveAs Filename:= _
"S:\KBR Forecast\KBR PEO-Equipment Requests\KBR PEO-Equipment Requests" & strtask & " " & "KBR Equipment Request Form" & " " & Format(Date, "MM-DD-YYYY") & "-" & Format(Now, "hh") & Format(Now, "mm") & Format(Now, "ss") & ".xlsm", FileFormat:= _
xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False

Dim Email_Subject, Email_Send_From, Email_Send_To, _
Email_Cc, Email_Bcc, Email_Body As String
Dim Mail_Object, Mail_Single As Variant
Email_Subject = "KBR PEO-Equipment Requests" & "_" & Format(Date, "yyyy-mm-dd")
'Email_Send_From = ""
Email_Send_To = "ryan.e.carr@dupont.com"
'Email_Cc = ""
'Email_Bcc = ""
'Email_Body = ""
On Error GoTo debugs
Set Mail_Object = CreateObject("Outlook.Application")
Set Mail_Single = Mail_Object.CreateItem(0)
With Mail_Single
.Subject = Email_Subject
.To = Email_Send_To
'.cc = Email_Cc
'.BCC = Email_Bcc
'.Body = Email_Body
.send
End With
debugs:
If Err.Description <> "" Then MsgBox Err.Description


MsgBox "Your form has been submitted"

Application.ScreenUpdating = True
ActiveWorkbook.Close

End Sub
 
@BigD,

I don't do a lot with Outlook, but it seems that you have not attached the file to the message. You are saving the Excel file, but never again refer to it after you initialize the Outlook application.

Hope that helps.

Regards,
Ken
 
Back
Top