Sending Email

  • Thread starter Thread starter Wolfy
  • Start date Start date
W

Wolfy

Guest
Hi

I have created a macro that sends an email message, using SendObject

I have created an add form and on this form when you click on the "Save" button, it saves the information and runs macro that sends an email message.
Docmd.RunMacro ("SendNew")

At first, it works fine everytime.

Now, I have a second form that views each record and I have a button when click will delete that record and run another macro that sends another email message. Once I delete a record and then open the add form and click the "Save" button, when it tries to run the macro it gives an error of action failed.

Then when I close the database and rerun it and I try to add it would work. and then when I delete something, adding would not work again.

anyone knows what is happening, please let me know. Thanks.

qhl
 
I may have had the same problem. Using the SendObject method, everything would work fine the first time I sent the email, but it would not work after that unless I shut down the database. This is documented on Microsoft's Premier Support as being a bug with the SendObject method. To get around this, I am now using the CreateObject method to open Outlook:

' Create the Outlook session.
Set objOutlook = CreateObject("Outlook.Application")

' Create the message.
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)

I then add my attachment(s) and set the To, CC, Subject, Body fields.

With objOutlookMsg
Set objOutlookAttach = .Attachments.Add(C:\ReportName.snp)
.To = strrecipient 'email addresses seperated bya semicolon
.Subject = strSubject ' the subject
.Body = strBody ' the message in the body of the email
.ReadReceiptRequested = bReadReceipt 'true or false

.Send
'or .Display to display the message instead of sending it
End With

I haven't had the problem since. This method actually works better because Outlook doesn't need to be open. You could resolve the email addresses for the To field, but if you are using Outlook 2000 with the security patch you will get the security warnings. If you need more info let me know.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom