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