Attaching a MDB file and nailing it from an access Form.

J

Jim/Chris

I am not sure if this will work with Outlook express. It
was designed for outlook. Some of our people only use
Outlook express and it does work for them
Create the function below
The strto, strsubject, varbody, strattachment can be added
on the function string when called instead of in the
function itself

Jim

Function SendEMail()
Dim strTo As String, strSubject As String, _
varBody As Variant, strCC As String, _
strBCC As String, strAttachment As String

strTo = "email adress"
strSubject = "this is a test"
varBody = "This is the body"
strAttachment = "c:\my documents\bianca1.wav"

'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
 

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