View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Terry Terry is offline
external usenet poster
 
Posts: 10
Default What 's wrong with the coding? -- about using outlook to send attachment in excel

Hello
I would like to send the excel file through Outlook with attachment. The email addresses are on the column B. And I
use the following code to do so. The problem occurred on the attachment part. The error message is "Internal Application
Error" . Could you help me to find out the problem from the following coding?
Thanks in advance

Regards
Terr

Sub send(
Dim objOutlook As Outlook.Applicatio
Dim objEMailMsg As Outlook.mailite
Dim myAttachment
Dim Recor
Dim Sh
Dim

Set objOutlook = New Outlook.Applicatio
Set objEMailMsg = objOutlook.CreateItem(olMailItem
Set myAttachments = objEMailMsg.Attachment
Record = Application.CountA(Sheets("Sheet1").Range("B:B")) +
With objEMailMs
x =
D
Sht = Worksheets("Sheet1").Cells(x, 2

Set myrecipient = .Recipients.Add(Sht
myrecipient.Type = olT
x = x +
Loop Until x = Recor

.Subject = "Testing by Terry
.htmlbody = "hello
.displa
.sen

myAttachments.Add "C:\Documents and Settings\terry\Desktop\email.xls" *****

End Wit

End Sub