Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 213
Default Need Help with SendMail

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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Need Help with SendMail

Hi AccessHelp

You can use a on error code

On Error Resume Next
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
On Error GoTo 0

--
Regards Ron de Bruin
http://www.rondebruin.nl


"AccessHelp" wrote in message ...
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




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 213
Default Need Help with SendMail

Ron,

Thanks very much for your help. It works. I do have one more question.

Is there a code that we can write to prevent the message from Outlook
popping-up?

Thanks again.

"Ron de Bruin" wrote:

Hi AccessHelp

You can use a on error code

On Error Resume Next
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
On Error GoTo 0

--
Regards Ron de Bruin
http://www.rondebruin.nl


"AccessHelp" wrote in message ...
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





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Need Help with SendMail

See
http://www.rondebruin.nl/mail/prevent.htm

--
Regards Ron de Bruin
http://www.rondebruin.nl


"AccessHelp" wrote in message ...
Ron,

Thanks very much for your help. It works. I do have one more question.

Is there a code that we can write to prevent the message from Outlook
popping-up?

Thanks again.

"Ron de Bruin" wrote:

Hi AccessHelp

You can use a on error code

On Error Resume Next
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
On Error GoTo 0

--
Regards Ron de Bruin
http://www.rondebruin.nl


"AccessHelp" wrote in message ...
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







  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Need Help with SendMail


Sub send()

ActiveWorkbook.SendMail "

End Sub

Try the code above to get rid of the warning but to no avail. Is there
something I am missing.

Thanks for your answer


--
karnak
------------------------------------------------------------------------
karnak's Profile: http://www.excelforum.com/member.php...o&userid=28918
View this thread: http://www.excelforum.com/showthread...hreadid=485684



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Need Help with SendMail

Have you read the information in the link ?
http://www.rondebruin.nl/mail/prevent.htm



--
Regards Ron de Bruin
http://www.rondebruin.nl


"karnak" wrote in message
...

Sub send()

ActiveWorkbook.SendMail "

End Sub

Try the code above to get rid of the warning but to no avail. Is there
something I am missing.

Thanks for your answer


--
karnak
------------------------------------------------------------------------
karnak's Profile: http://www.excelforum.com/member.php...o&userid=28918
View this thread: http://www.excelforum.com/showthread...hreadid=485684



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
sendmail Eef New Users to Excel 4 March 23rd 09 05:55 PM
Sendmail Mattlynn via OfficeKB.com Excel Discussion (Misc queries) 4 August 8th 08 12:21 PM
Sendmail Malcolm Excel Programming 1 November 5th 04 05:37 PM
Sendmail rbaxter[_7_] Excel Programming 1 September 15th 04 04:24 PM
SendMail and BCC Darrin Henry Excel Programming 1 September 13th 03 03:18 PM


All times are GMT +1. The time now is 01:59 AM.

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

About Us

"It's about Microsoft Excel"