Logo 
Search:

MS Office Answers

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds
  Question Asked By: Bonni Garcia   on Nov 01 In MS Office Category.

  
Question Answered By: Jawna Mohammad   on Nov 01

This is what I came up with, and what do you know?

It even works asit should.

Rick, as you can see I used some of your code, however modified and
added some code.


Sub Send_Mail()
'
Dim wb As Workbook
Dim txtSubject As String
Dim txtBodyText As String
Application.Visible = False
Application.ScreenUpdating = False

On Error GoTo ZZ:

Set wb = ActiveWorkbook
With wb
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(olMailItem)
With OutMail
.To = "<E-mail Address>"
.CC = ""
.BCC = ""
.Subject = "VaF 2nd Report"
.Body = "Colleague, " & vbCrLf & vbCrLf & "<Body Text in Here>" &
vbCrLf & vbCrLf & "With Kind Regards" & vbCrLf & vbCrLf & "Johan"
.Attachments.Add "C:\SAP\<filename>.xls"
.Display
Application.SendKeys "%S"
End With
End With
Set OutMail = Nothing
Set OutApp = Nothing
Application.ScreenUpdating = True

Exit Sub
ZZ:
D = MsgBox("The file  to be attached could not be found, " & vbCr &
"please check and try again.", 16, "")
If D = vbOK Then
Application.DisplayAlerts = False
Application.Quit
End If
End Sub

Share: 

 

This Question has 4 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on VB code to send Mail from Excel? Or get search suggestion and latest updates.


Tagged: