XL98: SendMail Method Returns Run-time Error 1004 (241421)
The information in this article applies to:
- Microsoft Excel 98 Macintosh Edition
This article was previously published under Q241421 SYMPTOMS
When you run a macro that uses the SendMail method, you may receive the following error message:
Run-time error '1004':
Method 'SendMail' of object '_Workbook' failed
CAUSE
The SendMail method only works with MAPI mail clients, such as Starnine Mail. In these clients, the MailSystem property returns a value of 1.
RESOLUTIONMicrosoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements.
The following sample macro verifies if the mail client that you are using is a MAPI client. Then, based on the result, the macro either uses the SendMail method or an alternative method using the Mail Recipient CommandBar control.
Sub Check_Mail()
Select Case Application.MailSystem
Case xlMAPI
ThisWorkbook.SendMail Recipients:="<valid e-mail address>"
Case xlNoMailSystem
MsgBox "no mail client"
Case Else
Application.CommandBars("worksheet menu bar") _
.Controls("File").Controls("Send To").Controls("Mail Recipient...").Execute
End Select
End Sub
NOTE: In the above code, replace <valid e-mail address> with the e-mail address of a person to whom you can usually send an e-mail message via your e-mail client.
When you run the Check_Mail macro, it sends your workbook to the specified person if you are using a MAPI e-mail client. If you are not using a MAPI e-mail client, your e-mail client is started, but you have to type the person's e-mail address in the new message that is created.
REFERENCESFor additional information about how to run sample code, click the article number below
to view the article in the Microsoft Knowledge Base:
181058 OFF98: How to Run Sample Code from Knowledge Base Articles
| Modification Type: | Minor | Last Reviewed: | 10/10/2006 |
|---|
| Keywords: | kberrmsg kbprb KB241421 |
|---|
|