Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default What 's wrong with the coding? -- about using outlook to send attachment in excel

Seemed to me when I ran it that putting the .send AFTER
myattachments.add made it work.

I also specifically defined
Dim myAttachments As Outlook.Attachments

Simon


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,
Terry

Sub send()
Dim objOutlook As Outlook.Application
Dim objEMailMsg As Outlook.mailitem
Dim myAttachments
Dim Record
Dim Sht
Dim x

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

Set myrecipient = .Recipients.Add(Sht)
myrecipient.Type = olTo
x = x + 1
Loop Until x = Record

.Subject = "Testing by Terry"
.htmlbody = "hello"
.display
.send

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

End With

End Sub

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't send an attachment in Excel 2007 Stephen New Users to Excel 9 November 6th 07 05:27 PM
Can't send an attachment in Excel 2007 Stephen Excel Discussion (Misc queries) 0 November 2nd 07 10:55 PM
Excel 03 - Send Attachment (can't minimize Outlook window) KKate Excel Discussion (Misc queries) 0 August 10th 07 01:20 AM
My send to in excel/word does not offer send as attachment Mstink Excel Discussion (Misc queries) 11 March 16th 06 02:49 PM
cant send email attachment from excel DKT New Users to Excel 8 November 22nd 05 01:25 AM


All times are GMT +1. The time now is 08:43 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"