sending email without outlook messages

J

JNW

I've already checked out http://www.rondebruin.nl/mail/prevent.htm

I used the alt command to send the message. It worked great, but, all of a
sudden is not working anymore. I've downloaded the ClickYes program, but as
this application will be distributed widely I don't want to have to install
it on every computer.

The email is being created and displayed but not sent.

I've posted my code below. And I'm using xl2002 on xp Professional.

Thanks

Sub ResAlertForm_Email()
'This example send the last saved version of the Activeworkbook
'You must add a reference to the Microsoft outlook Library
Dim OutApp As Object
Dim OutMail As Object
Dim EmailAddr As String
Dim Subj As String

EmailAddr = Sheets("Reservation Alert Form").Range("T8")
Subj = Sheets("Reservation Alert Form").Range("B5") 'form title

Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)

With OutMail
.To = EmailAddr
.CC = ""
.BCC = ""
.Subject = "***TEST*** " & Subj
.Body = Subj
.Attachments.Add ActiveWorkbook.FullName
.Display 'or use .send and remove the next two lines
Application.Wait (Now + TimeValue("0:00:02"))
Application.SendKeys "%S"
End With
Set OutMail = Nothing
Set OutApp = Nothing

ActiveWorkbook.Save
ActiveWorkbook.Close
Application.DisplayAlerts = True
End Sub
 
R

Ron de Bruin

Hi JNW

Yes it is not reliable the SendKeys code.
You can try to wait longer then 2 seconds ?

Don't use the Send keys code if you want to distributed the code widely
The CDO code is great from my site but also not to distributed the code widely
 
J

JNW

Thanks for the reply. This is not absolutely necessary in the program (I
would think that most people understand that the email needs to be sent), but
would be nice.

Do you have any suggestions for something that would be reliable for wide
distribution?
 
R

Ron de Bruin

Hi

There are third party programs that you can use but I don't have experience with it.



Use this to avoid the error if the user say No in the dialog



On Error Resume Next



On Error GoTo 0
 
J

JNW

Thanks Ron, I'll do that.

Ron de Bruin said:
Hi

There are third party programs that you can use but I don't have experience with it.



Use this to avoid the error if the user say No in the dialog



On Error Resume Next




On Error GoTo 0
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top