Results 1 to 3 of 3

Thread: sending email from Access 2000 [resolved]

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2003
    Location
    Toronto
    Posts
    3

    Unhappy 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:
    1. Function SendFile(fname As String) As Boolean
    2. 'create an error handler
    3. On Error GoTo SendFile_Err
    4.     'set default return value
    5.     SendFile = False
    6.    
    7.     Dim objSession As Object
    8.     Dim objMessage As Object
    9.     Dim objRecipeint As Object
    10.    
    11.     'declare some other utility variable
    12.     Dim sSubject    As String
    13.     Dim sText       As String
    14.     Dim sName       As String
    15.    
    16.     sName = "[email protected]"
    17.     'set up the email message test
    18.     sText = "This is an automated email"
    19.     sSubject = "Today's report"
    20.    
    21.     'start with the top of the mapi hierarchy --
    22.     'the session object
    23.     Set objSession = CreateObject("mapi.session")  '****<-- error here
    24.         'use the local Outlook Express default profile
    25.         objSession.LogOn profilename:="Microsoft Outlook"
    26.        
    27.         'now create a new message object
    28.         Set objMessage = objSession.outbox.messages.Add
    29.             'feed in required property values for the message
    30.             objMessage.Subject = sSubject
    31.             objMessage.Text = sText
    32.             'create a new recipeint for this message
    33.             Set objRecipient = objMessage.Recipients.Add
    34.                 'and set it's properties
    35.                 objRecipient.name = sName
    36.                 objRecipient.Type = 1
    37.                 'mak sure the emial address is resolved
    38.                 objRecipeint.resolve
    39.    
    40.                 'now sent the message
    41.                 objMessage.Send showdialog:=False
    42.                
    43. SendFile_Exit:
    44.     Exit Function
    45.    
    46. SendFile_Err:
    47.     MsgBox Err.Number & vbCrLf & Err.Description & vbCrLf & Err.Source
    48.    
    49. End Function
    Last edited by nike; Nov 13th, 2003 at 11:34 AM.
    nike

  2. #2
    Hyperactive Member
    Join Date
    Nov 1999
    Location
    Galway, Ireland
    Posts
    316
    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")
    Slan

  3. #3

    Thread Starter
    New Member
    Join Date
    Nov 2003
    Location
    Toronto
    Posts
    3
    Thank you john_murphy for the help
    nike

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width