-----Original Message-----
I have created a module and I have copied your code. I have changed ....
strTo = "SendTo"
strSubject = "Order:"
varBody = ""
strAttachment = "c:\order.txt"
and I have created a button and in OnClick I have put '=SendEmail()'.
when I press the button I take error message ....
****************************************************************************
*
The expression OnClick you entered as the event property setting produced
the following error:
The expression you entered has a function name that ORDERS can't find.
*The expression may not result in the name of a macro, the name of a
user-defined function, or [Event Procedure].
*There may have been an error evaluating the function, event or macro.
****************************************************************************
**
Do I have to do something additional?
thanks
? "Jim/Chris said:
I use Outlook. I created this function below. Actually
modified one from one of the MVP's. Works very good for
me. Then add a button on your form to run this function.
This is very flexible because the email paramaters could
come from the form
Jim
Function SendEMail()
Dim strTo As String, strSubject As String, _
varBody As Variant, strCC As String, _
strBCC As String, strAttachment As String
strTo = "Insert to email address"
strSubject = "Insert subject"
varBody = "insert body of message"
strAttachment = "insert full fuile name"
'Start Outlook
Dim olApp As Outlook.Application
Set olApp = CreateObject("Outlook.Application")
'Logon
Dim olNs As Outlook.NameSpace
Set olNs = olApp.GetNamespace("MAPI")
olNs.Logon
'Send a message
Dim olMail As Outlook.MailItem
Set olMail = olApp.CreateItem(olMailItem)
'Fill Out and Send Message
olMail.To = strTo
olMail.CC = strCC
olMail.BCC = strBCC
olMail.Subject = strSubject
olMail.Body = varBody
If Len(strAttachment) <> 0 Then
olMail.Attachments.Add (strAttachment)
End If
olMail.Send
Set olNs = Nothing
Set olMail = Nothing
Set olApp = Nothing
End Function
.