Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Need to send Outlook E-mail from Excel VBA without warnings.

I'm trying to automate the sending of a spreadsheet from via Outlook. I have
the code in place to build the spreadsheet and setup the Outlook Application
object and the MailItem object. It sends the message but gives me a warning
that requires a user interaction. Is there a way to bypass this warning?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 139
Default Need to send Outlook E-mail from Excel VBA without warnings.

Hi,Prz59

Display Month

Public Declare Function SetTimer Lib "user32" _
(ByVal hwnd As Long, ByVal nIDEvent As Long, ByVal uElapse As Long,
ByVal lpTimerfunc As Long) As Long
Public Declare Function KillTimer Lib "user32" _
(ByVal hwnd As Long, ByVal nIDEvent As Long) As Long
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Function WinProcA(ByVal hwnd As Long, ByVal uMsg As Long, ByVal idEvent As
Long, ByVal SysTime As Long) As Long
KillTimer 0, idEvent
DoEvents
Sleep 100
' Alt + s send mail
Application.SendKeys "%s"
End Function
Sub SendMail()
Dim objOL As Object
Dim itmNewMail As Object
'Microsoft Outlook object
Set objOL = CreateObject("Outlook.Application")
Set itmNewMail = objOL.CreateItem(olMailItem)
With itmNewMail
.Subject = "chijanzen Mail Test" 'Subject
.Body = Application.UserName & "Email test" 'Body
.To = " 'User
.Attachments.Add ThisWorkbook.FullName 'send ThisWorkbook
.Display 'Display
SetTimer 0, 0, 0, AddressOf WinProcA
End With
Set objOL = Nothing
Set itmNewMail = Nothing
End Sub

--
http://www.vba.com.tw/plog/


"Prz59" wrote:

I'm trying to automate the sending of a spreadsheet from via Outlook. I have
the code in place to build the spreadsheet and setup the Outlook Application
object and the MailItem object. It sends the message but gives me a warning
that requires a user interaction. Is there a way to bypass this warning?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Need to send Outlook E-mail from Excel VBA without warnings.

Hi Prz59,

See Ron De Briun's suggestions at:

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


---
Regards,
Norman



"Prz59" wrote in message
...
I'm trying to automate the sending of a spreadsheet from via Outlook. I
have
the code in place to build the spreadsheet and setup the Outlook
Application
object and the MailItem object. It sends the message but gives me a
warning
that requires a user interaction. Is there a way to bypass this warning?



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Need to send Outlook E-mail from Excel VBA without warnings.

It's not working. It displays the message with the attachment, but never
sends it.

I had to create the WinProcA Function in a module outside the WorkBook code
for it to run using the AddressOf operator. It doesn't appear to go into that
function when I step through the code in the de-bugger.

"chijanzen" wrote:

Hi,Prz59

Display Month

Public Declare Function SetTimer Lib "user32" _
(ByVal hwnd As Long, ByVal nIDEvent As Long, ByVal uElapse As Long,
ByVal lpTimerfunc As Long) As Long
Public Declare Function KillTimer Lib "user32" _
(ByVal hwnd As Long, ByVal nIDEvent As Long) As Long
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Function WinProcA(ByVal hwnd As Long, ByVal uMsg As Long, ByVal idEvent As
Long, ByVal SysTime As Long) As Long
KillTimer 0, idEvent
DoEvents
Sleep 100
' Alt + s send mail
Application.SendKeys "%s"
End Function
Sub SendMail()
Dim objOL As Object
Dim itmNewMail As Object
'Microsoft Outlook object
Set objOL = CreateObject("Outlook.Application")
Set itmNewMail = objOL.CreateItem(olMailItem)
With itmNewMail
.Subject = "chijanzen Mail Test" 'Subject
.Body = Application.UserName & "Email test" 'Body
.To = " 'User
.Attachments.Add ThisWorkbook.FullName 'send ThisWorkbook
.Display 'Display
SetTimer 0, 0, 0, AddressOf WinProcA
End With
Set objOL = Nothing
Set itmNewMail = Nothing
End Sub

--
http://www.vba.com.tw/plog/


"Prz59" wrote:

I'm trying to automate the sending of a spreadsheet from via Outlook. I have
the code in place to build the spreadsheet and setup the Outlook Application
object and the MailItem object. It sends the message but gives me a warning
that requires a user interaction. Is there a way to bypass this warning?

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
Macro to send a mail to outlook [email protected] Excel Discussion (Misc queries) 1 August 24th 06 12:48 PM
How can I use Outlook express to send mail rather than Outlook by VBA code new.microsoft.com Excel Programming 5 August 3rd 05 03:45 PM
Help for Send Mail via Outlook new.microsoft.com Excel Programming 5 August 2nd 05 01:00 AM
How can I use Outlook express to send mail rather than Outlook by VBA code new.microsoft.com Excel Programming 1 August 1st 05 12:45 PM
Send mail from vba with the outlook distribution list eli Excel Programming 0 January 2nd 04 10:21 PM


All times are GMT +1. The time now is 08:16 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"