Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hello,
I copied the codes below from Ron de Bruin's web site and used it for my Excel to email using Outlook. Everything is fine until when I get the message from Outlook about a program is trying to send something and whether I want to send it. If I click "Yes", the email and attachement are sent. However, when I click "No", I got this error message "Run-time error '287': Application-defined or object-defined error". I have an option of "End" or "Debug". When I click on "Debug", it points me to the code ".Send" in the below coding. My first question is can I write a code to receive the pop-up window from Outlook and it would send it automatically? If I can't, (my second question is) what code I should write to avoid the above error message when a user clicks on "No" on the Outlook window. Thanks. Here are the codes: Sub Mail_ActiveSheet_Outlook() 'You must add a reference to the Microsoft outlook Library Dim OutApp As Outlook.Application Dim OutMail As Outlook.MailItem Dim wb As Workbook Dim strdate As String strdate = Format(Now, "dd-mm-yy h-mm-ss") Application.ScreenUpdating = False ActiveSheet.Copy Set wb = ActiveWorkbook With wb .SaveAs "Part of " & ThisWorkbook.Name _ & " " & strdate & ".xls" Set OutApp = CreateObject("Outlook.Application") Set OutMail = OutApp.CreateItem(olMailItem) With OutMail .To = " .CC = "" .BCC = "" .Subject = "This is the Subject line" .Body = "Hi there" .Attachments.Add wb.FullName 'You can add other files also like this '.Attachments.Add ("C:\test.txt") .Send 'or use .Display End With .ChangeFileAccess xlReadOnly Kill .FullName .Close False End With Application.ScreenUpdating = True Set OutMail = Nothing Set OutApp = Nothing End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
sendmail | New Users to Excel | |||
Sendmail | Excel Discussion (Misc queries) | |||
Sendmail | Excel Programming | |||
Sendmail | Excel Programming | |||
SendMail and BCC | Excel Programming |