Create an E-mail from Access

B

Brad

Thanks for taking the time to read my question.

I posed a message a few days ago and got a great response
from Arvin Meyer. I am just having some problems with
the DIM statements. I am getting a "Compile Error: User-
defined type not defined" error. What does this mean,
and how can I fix this problem. I am using Access 97.

Thanks again for the help, and hats off to Arvin.

Brad



Private Sub Command0_Click()
'Arvin Meyer 03/12/1999
'Updated 7/21/2001
On Error GoTo Error_Handler

Dim objOutlook As Outlook.Application
Dim objEmail As Outlook.MailItem

Set objOutlook = CreateObject("Outlook.application")
Set objEmail = objOutlook.CreateItem(olMailItem)

With objEmail
.To = "(e-mail address removed)"
.Subject = "Look at this sample attachment"
.body = "The body doesn't matter, just the attachment"
.Attachments.Add "C:\Test.htm"
'.attachments.Add "c:\Path\to\the\next\file.txt"
.Send
'.ReadReceiptRequested
End With

Exit_Here:
Set objOutlook = Nothing
Exit Sub

Error_Handler:
MsgBox Err & ": " & Err.Description
Resume Exit_Here

End Sub
 
G

GVaught

Are you sure you got all of Arvin's code for this. Is there a class or
standard module that is a supplement to this code that needs to be in your
database?
 
G

Guest

Brad said:
Thanks for taking the time to read my question.

I posed a message a few days ago and got a great response
from Arvin Meyer. I am just having some problems with
the DIM statements. I am getting a "Compile Error: User-
defined type not defined" error. What does this mean,
and how can I fix this problem. I am using Access 97.

Thanks again for the help, and hats off to Arvin.

Brad

Private Sub Command0_Click()
'Arvin Meyer 03/12/1999
'Updated 7/21/2001
On Error GoTo Error_Handler

Dim objOutlook As Outlook.Application
Dim objEmail As Outlook.MailItem

Set objOutlook = CreateObject("Outlook.application")
Set objEmail = objOutlook.CreateItem(olMailItem)

With objEmail
.To = "(e-mail address removed)"
.Subject = "Look at this sample attachment"
.body = "The body doesn't matter, just the attachment"
.Attachments.Add "C:\Test.htm"
'.attachments.Add "c:\Path\to\the\next\file.txt"
.Send
'.ReadReceiptRequested
End With

Exit_Here:
Set objOutlook = Nothing
Exit Sub

Error_Handler:
MsgBox Err & ": " & Err.Description
Resume Exit_Here

End Sub

Before this code will work, you have to have the reference to
the Outlook Library enabled. I don't remember the exact name,
but, while you have the code edit window open, from the
toolbar, look in Tools>References, and look in the list for
and entry that contains something like Microsoft Outlook ...
Library. If is is not checked, check it.
gm
 

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