|
-
Nov 12th, 2003, 11:57 AM
#1
Thread Starter
New Member
sending email from Access 2000 [resolved]
I need help!
I'm using Access 2000 and am trying to send email with attachment (I don't know how to add attachments either). I'm trying to use MAPI, I've included the MAPIMail 1.0 Type Library, Mail Massage 1.0 Type Library and MAPIForm object Type Library already.
I still get error when I try to create the session object.
Does anyone know how to resolve this problem????
VB Code:
Function SendFile(fname As String) As Boolean
'create an error handler
On Error GoTo SendFile_Err
'set default return value
SendFile = False
Dim objSession As Object
Dim objMessage As Object
Dim objRecipeint As Object
'declare some other utility variable
Dim sSubject As String
Dim sText As String
Dim sName As String
'set up the email message test
sText = "This is an automated email"
sSubject = "Today's report"
'start with the top of the mapi hierarchy --
'the session object
Set objSession = CreateObject("mapi.session") '****<-- error here
'use the local Outlook Express default profile
objSession.LogOn profilename:="Microsoft Outlook"
'now create a new message object
Set objMessage = objSession.outbox.messages.Add
'feed in required property values for the message
objMessage.Subject = sSubject
objMessage.Text = sText
'create a new recipeint for this message
Set objRecipient = objMessage.Recipients.Add
'and set it's properties
objRecipient.name = sName
objRecipient.Type = 1
'mak sure the emial address is resolved
objRecipeint.resolve
'now sent the message
objMessage.Send showdialog:=False
SendFile_Exit:
Exit Function
SendFile_Err:
MsgBox Err.Number & vbCrLf & Err.Description & vbCrLf & Err.Source
End Function
Last edited by nike; Nov 13th, 2003 at 11:34 AM.
nike
-
Nov 13th, 2003, 06:08 AM
#2
Hyperactive Member
Set ObjApp = CreateObject("Outlook.Application")
Set mapi = ObjApp.GetNamespace("MAPI")
Set email = ObjApp.CreateItem(0)
email.Recipients.Add ("[email protected]")
email.Subject = "Here is the Subject"
email.Body = "Some Stuff..." & Chr(13)
email.Display
email.Attachments.Add ("c:\myfile.doc")
-
Nov 13th, 2003, 11:35 AM
#3
Thread Starter
New Member
Thank you john_murphy for the help
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|