Results 1 to 13 of 13
  1. #1
    Join Date
    May 2007
    Posts
    92

    Unanswered: Automatically Generate An Email to the User

    Hi Everyone,

    Does Anyone knows how to automatically generate an email to the user?

    I am currently doing the reservation system such that I want the email to automatically generate out and send to the Users Lotus Note Mail after the user clicks the reserve items in the system ?

    How can possible to do that?

    Thank....

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    wonder if anyone has had this problem before on dbforums......

    lets try the search and see
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Feb 2007
    Posts
    15
    Hello StevenE,

    Sometimes ago I had to wrote a vb code to send via email a receipt of payment. The code is as follows:

    'Get the email address from table.
    'Here I am creating an instance of my recordset.
    Call vbProcs.Registos
    'Here I will check my table for email address of client.
    strSQL = "SELECT * FROM tblParticipantes WHERE tblParticipantes.nomeparticipante = '" _
    & cboInscricaoParticipante.Text & "'"
    rsRegistos.Open strSQL, cnConexao
    lngCodigoParticipante = rsRegistos("numeroparticipante")
    rsRegistos.Close
    strSQL = "SELECT tblResponsaveis.email FROM tblResponsaveis WHERE " _
    & "tblResponsaveis.numeroparticipante = " & lngCodigoParticipante
    rsRegistos.Open strSQL, cnConexao
    Now the part that you are interested in.

    MAPISession1.SignOn

    MAPIMessages1.SessionID = MAPISession1.SessionID
    MAPIMessages1.MsgIndex = -1
    MAPIMessages1.RecipDisplayName = rsRegistos("email")
    MAPIMessages1.MsgSubject = "Confirmação de inscrição em ATL"
    MAPIMessages1.MsgNoteText = "Vimos por este meio confirmar a inscrição de " _
    & cboInscricaoParticipante.Text & vbNewLine & " no " & cboInscricaoTurno.Text _
    & " turno do programa " & "de ATL " & cboInscricaoPrograma.Text
    MAPIMessages1.Send

    MAPISession1.SignOff

    Set rsRegistos = Nothing
    MsgBox "Mensagem enviada com sucesso!", vbOKOnly + vbInformation, "Interface Pedagógico"
    I hope this really helps you... if not just call me.

    Omnia in bonum.

    OS

  4. #4
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926

    Emailing Example mdb's

    Here's a couple of routines I use.
    Attached Files Attached Files
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  5. #5
    Join Date
    May 2007
    Posts
    92

    Generate An Email and Send to User straightaway

    Hi osilvaware and Paul,

    Thank for your suggestions..

    When I do this I got encounter 2 problems,

    1. The system will open up my lotus note email and prompt me the password before creating an email.

    2. I want the access system to create and send the email straight away to the user.

    For eg. When user click the reserve button, the email will be generated and send out to the user lotus email address straightaway instead of me clicking the send button in the lotus note. As for the Email, the sender will be my email address has fixed, the recipient will be the user. The subject and message are been written down in the mail to inform the user.

    How can i possibly to do that?

    Thank...

  6. #6
    Join Date
    May 2003
    Location
    Dallas
    Posts
    817
    Provided Answers: 5
    docmd.sendmessage - for the lazy
    in all seriousness - I like the outlook object model and I bet PK probably has an example in that zip file - am I right?
    Dale Houston, TX

  7. #7
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    I can't recall axsprog. I'd have to take a look at it again. The routine uses the docmd.sendojbect method retrieving names from a stored table to loop through and email to.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  8. #8
    Join Date
    May 2003
    Location
    Dallas
    Posts
    817
    Provided Answers: 5
    And I bet it works. I miss the days before Outlook flashed the warning about other programs sending email. For awhile I used the CDO (Collective Data Objects) to get around this - but Microsoft "caught on" - There really is not a way to turn that off (Even if they have Exchange - they risk security breaches if they remove that) in Outlook is there?
    Dale Houston, TX

  9. #9
    Join Date
    Jun 2007
    Posts
    74
    This is the function you need...

    You call the funtion and pass the Subject, Attachment, Recipient, and Body Text. You will see that there is a line where you can enter your password. By doing this you are not prompted for anything. If your company (like mine) has a security banner that displays when Notes is launched that will still display. But if you have that problem I can tell you how to prevent the banner from displaying as well. I use this in Excel but there is no reason it should not work in Access.... You will have to find the infor for your mail server if you do not know it.

    Code:
     
     
    Public Function SendNotesMail(Subject As String, Attachment As String, recipient As String, BodyText As String)
    'Declare Variables
        Dim Maildb As Object
        Dim MailDoc As Object
        Dim Body As Object
        Dim Session As Object
    'Start a session to notes
        Set Session = CreateObject("Lotus.NotesSession")
    'This line prompts for password of current ID noted in Notes.INI
        'Call Session.Initialize
    'Or use below to supply password of the current ID
        Call Session.Initialize("Type Password Here")
    'Open the mail database in notes
        Set Maildb = Session.GETDATABASE("DWMAIL03/MSVR/VERIZON", "mail3\bl8x0vh.nsf")
        If Not Maildb.IsOpen = True Then
        Call Maildb.Open
        End If
    'Create the mail document
        Set MailDoc = Maildb.CREATEDOCUMENT
        Call MailDoc.ReplaceItemValue("Form", "Memo")
    'Set the recipient
        Call MailDoc.ReplaceItemValue("SendTo", recipient)
    'Set subject
        Call MailDoc.ReplaceItemValue("Subject", Subject)
    'Create and set the Body content
        Set Body = MailDoc.CREATERICHTEXTITEM("Body")
        Call Body.APPENDTEXT(BodyText)
    'Example to create an attachment (optional)
        Call Body.ADDNEWLINE(2)
        Call Body.EMBEDOBJECT(1454, "", Attachment)
    'Example to save the message (optional)
        MailDoc.SAVEMESSAGEONSEND = True
    'Send the document
    'Gets the mail to appear in the Sent items folder
        Call MailDoc.ReplaceItemValue("PostedDate", Now())
        Call MailDoc.SEND(False)
    'Clean Up
        Set Maildb = Nothing
        Set MailDoc = Nothing
        Set Body = Nothing
        Set Session = Nothing
    End Function
    Let me know if it does not work....

  10. #10
    Join Date
    May 2003
    Location
    Dallas
    Posts
    817
    Provided Answers: 5
    Brent thanks for the snippet for Lotus notes! I have added to my library (with your permission)
    Dale Houston, TX

  11. #11
    Join Date
    Jun 2007
    Posts
    74
    NP..

    There are versions of this that you can find on the web, but they are different. They typically do not work properly when you try to pass the password. I actually found this code on the Notes website. I wish I could take credit....

    Enjoy,
    Brent Blevins

  12. #12
    Join Date
    May 2007
    Posts
    92

    Automatically generate an email

    Hi,

    Thank everyone for your suggestions and helping in these thread..

    I got something to ask u, Brent regarding your codes..

    Where should i place the codes in for the Access application?

    Currently, i have created a button that can able the user to generate an email that can send to the recipent. But however, it will ask the user for the password in the lotus note...

    I wonder is these codes you suggest and recommend to me that can perform these conditions...

    For eg 1. I need the code that can help me to automatically generate an email and send to the recipent without having to ask the lotus note password and prompting me to click the send button.. I need to send the email straightaway to the recipent once they click the button..

    I currently using Microsoft Access 2003 n Lotus note 7..

    Thank for all your help..

    Thank..

  13. #13
    Join Date
    Jun 2007
    Posts
    74
    First you need to add the code from my previous post into a module. Then, in the "On Click" event of your "send" button, you will need to write code to generate your report or whatever text you want the e-mail to contain.

    You will then need to call the code that I added in my previous response. It is the code that you can use for sending a mail via Lotus Notes. Since you are going to be using this code for multiple users, you will have to determine how to handle the password issue. I do not think hardcoding paswords is a viable option. With that said, the users will have to provide their password by some means. Solution 1 and 2 provided below can easily be implemented in a way that does not require the users to click the send button in Notes.

    I will give you a few options to ponder.

    1) Add a textbox (with or without a password mask) and have the user enter their password in the box before you allow them to click the send button. This will require that you pass the value from the textbox into the mail function.

    2) When the user clicks the submit button you can display your own input box to prompt the user for their password.

    3) I certainly do not reccomend this method because it is more than likely a violation of your company's security policy but you could, (if your users agree) store email passwords in a table and use DLookup to find the password of the CurrentUser.

    To call the mail code you will need something like the following in the "On Click" event of your button.

    Code:
     
    strSubject = "Subject goes here"
    strAttachment = "File location goes here"
    strRecipient = "Recipient's e-mail adress goes here"
    strBody = "Body Text goes here"
    Call Mail_Utilities.SendNotesMail(strSubject, strAttachment, strRecipient, strBody, True)
    Does that 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
  •