Results 1 to 8 of 8
  1. #1
    Join Date
    May 2004
    Posts
    6

    Unanswered: Access Form to generate Outlook e-mail? Can it be done? Please help!!!

    I am 1st Line Helpdesk Administrator. I have an Access database used to store various User-related Information. I use a form to input new User details. Once a new User has been added to the network, I need to email the Manager with logon details. I have a template e-mail within Outlook for this.

    I would like to setup a system whereby once information has been entered into Access form, an email is generated taking information from my database such as Manager's e-mail address (to go into the 'To' field), Username, Password (to be put into the body of the email within surrounding text), etc.

    Can somebody please advise me on how to do this? I was told to look at COM (Component Object Model) which I read about but found it very interesting yet still unaware on where to start. I not too good at scripting, and querying so please bear in mind my level of knowledge in this area is pretty low!

    Thanks in advance.

  2. #2
    Join Date
    May 2004
    Location
    Moscow, Russia
    Posts
    29
    outlook or outlook express

    set used mail client as default

    use MAPI for sending messages

    sample code : http://kozin1.narod.ru/newsite/index.html?sendmapi.htm

  3. #3
    Join Date
    May 2004
    Posts
    6
    Please explain with more detail!

    NB - Im new to this game!

    Randeep

  4. #4
    Join Date
    May 2004
    Posts
    6
    PS - I don't understand the syrilic alphabet! The code is new to me. What language is it? Where would I run it from?

    In the meantime I will try and read about MAPI...

  5. #5
    Join Date
    May 2004
    Posts
    6
    It's ok, I have found out how to do it by using the SendObject method...

  6. #6
    Join Date
    Apr 2004
    Location
    metro Detroit
    Posts
    634
    Private Sub cmdEmail_Click()

    Dim msgTxt As Variant
    Dim objOutlook As Outlook.Application
    Dim objMailItem As Outlook.MailItem
    Dim blnCreated As Boolean



    blnCreated = False

    Set objOutlook = New Outlook.Application

    If IsNull(Me.{formcontrol with email address}) = True Or Me.{formcontrol with email address} = "" Then
    DoCmd.Hourglass False
    msgTxt = MsgBox("Unable to create an email for " & Me.{formcontrol with name} & Chr(13) & "No email address listed in the database.", vbOKOnly + vbInformation, "")
    Else
    DoCmd.Hourglass True
    Set objMailItem = objOutlook.CreateItemFromTemplate("{outlook template path}")

    With objMailItem
    .To = Me.{formcontrol with email address}
    .Save
    ' .Send
    blnCreated = True
    End With

    End If

    If blnCreated Then
    msgTxt = MsgBox("Finished creating email(s). The email(s) are in your Outlook 'Drafts' folder.", vbOKOnly, "")
    Else
    msgTxt = MsgBox("Email Failed.", vbOKOnly, "")
    End If

    DoCmd.Hourglass False

    End Sub


    Make sure you have a reference to the Outlook Object Library

    Replace text between {}

    This will save an unsent email to the user's Draft folder, to send the email take out the .Save line and uncomment the .Send line

    There is a .Body property that can be used to customize the body text and a few other properties to play with

  7. #7
    Join Date
    May 2012
    Posts
    89
    Hi im want to build a some what similar database.
    The only thing im not getting like i want it is the email i want the info stored in the database to not be in a attachment but just in the emal itself...
    The mail im using is outlook.

  8. #8
    Join Date
    Mar 2009
    Location
    Gatineau, Quebec Canada
    Posts
    147
    Provided Answers: 1
    My experience using Outlook as a mailer has not been good. I prefer the CDO library. There are examples on the web of dynamically changing the message in the property "TextBody" or "HTMLbody". To get you started, look at Welcome to PaulSadowski.com.

    Regards

    J Smith
    Aylmer, Quebec, Canada

Posting Permissions

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