ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Email and Excel Problem (https://www.excelbanter.com/excel-worksheet-functions/89970-email-excel-problem.html)

carl

Email and Excel Problem
 
I've been using this code and it has been working great:

'Sub Mail_ActiveSheet_Body()
Dim OutApp As Outlook.Application
Dim OutMail As Outlook.MailItem
Application.ScreenUpdating = False
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(olMailItem)
With OutMail
.To = "abc.com"
.CC = "efg.com"
.BCC = ""
.Subject = Sheets("trading").Range("A9").Value
.HTMLBody = SheetToHTML(ActiveSheet)
.Send 'or use .Display

Now when I run the macro, I get an Outlook message that

" A program is trying to automatically send e-mail on your behalf. Do you
want to allow this ?

The window gives me choices Yes, No, Help.

If I say yes. the email goes out. If I say no, the vba gets stuck on the
last line of the code above.

Is there any way to stop this outlook message - speed is very important in
my application and this Outlook message really slows things down.

Thank you in advance.


Ron de Bruin

Email and Excel Problem
 
See
http://www.rondebruin.nl/mail/prevent.htm



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


"carl" wrote in message ...
I've been using this code and it has been working great:

'Sub Mail_ActiveSheet_Body()
Dim OutApp As Outlook.Application
Dim OutMail As Outlook.MailItem
Application.ScreenUpdating = False
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(olMailItem)
With OutMail
.To = "abc.com"
.CC = "efg.com"
.BCC = ""
.Subject = Sheets("trading").Range("A9").Value
.HTMLBody = SheetToHTML(ActiveSheet)
.Send 'or use .Display

Now when I run the macro, I get an Outlook message that

" A program is trying to automatically send e-mail on your behalf. Do you
want to allow this ?

The window gives me choices Yes, No, Help.

If I say yes. the email goes out. If I say no, the vba gets stuck on the
last line of the code above.

Is there any way to stop this outlook message - speed is very important in
my application and this Outlook message really slows things down.

Thank you in advance.




Bob Phillips

Email and Excel Problem
 
See http://www.rondebruin.nl/mail/prevent.htm

--

HTH

Bob Phillips

(remove nothere from the email address if mailing direct)

"carl" wrote in message
...
I've been using this code and it has been working great:

'Sub Mail_ActiveSheet_Body()
Dim OutApp As Outlook.Application
Dim OutMail As Outlook.MailItem
Application.ScreenUpdating = False
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(olMailItem)
With OutMail
.To = "abc.com"
.CC = "efg.com"
.BCC = ""
.Subject = Sheets("trading").Range("A9").Value
.HTMLBody = SheetToHTML(ActiveSheet)
.Send 'or use .Display

Now when I run the macro, I get an Outlook message that

" A program is trying to automatically send e-mail on your behalf. Do you
want to allow this ?

The window gives me choices Yes, No, Help.

If I say yes. the email goes out. If I say no, the vba gets stuck on the
last line of the code above.

Is there any way to stop this outlook message - speed is very important in
my application and this Outlook message really slows things down.

Thank you in advance.





All times are GMT +1. The time now is 02:27 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com