View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Howard31 Howard31 is offline
external usenet poster
 
Posts: 100
Default CreateObject("Outlook.Application")

Hi,

I have procedure for sending mail. The problem is that the procedure will
work the first time it is executed but not the second time then the third
time it will work but not the fourth time and so on.

The sendEmail procedure is below.

Any help will be very much appreciated!

Public Sub sendMail()
On Error Resume Next

Dim oLApp As Object
Dim eMail As Object
Dim thisWb As String


thisWb = ThisWorkbook.Path & "\" & ThisWorkbook.Name
Set oLApp = CreateObject("Outlook.Application")
Set eMail = oLApp.CreateItem(olMailItem)

With eMail
.To = "
.Subject = "some subject"
.Attachments.Add (thisWb)
.Display
End With

Set eMail = Nothing
Set oLApp = Nothing
End Sub