Results 1 to 3 of 3
  1. #1
    shod90 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2016
    Posts
    134

    Automatic send emails when some action happens on form.

    Dear All,


    Currently i am working on a small project which focus on listing people that have an internet connection through firewall.
    I created a db that saves all people which have internet connection by adding them to a continuous form , I need after adding that user automatically send an email to manager tell him that there is a new user has been added .
    I know how to send emails from form to outlook , But i need to more automate the process .

  2. #2
    shod90 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2016
    Posts
    134
    I found that code and it's running very well for me
    Code:
    Dim iMsg As Object
        Dim iConf As Object
        Dim strbody, myemail, mypassword As String
        Dim Flds As Variant
        myemail = "Email"
        mypassword = "Password"
        Set iMsg = CreateObject("CDO.Message")
        Set iConf = CreateObject("CDO.Configuration")
        iConf.Load -1
        Set Flds = iConf.Fields
        With Flds
            .Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
            .Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
            .Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = myemail
            .Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = mypassword
            .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"
            .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
            .Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
            .Update
        End With
        With iMsg
            Set .Configuration = iConf
            .To = Me.tomail
            .From = """" & "SenderID" & """ <" & myemail & ">"
            .Subject = Me.sub
            .HTMLBody = "HTML code should be here "
            .Send
        End With

  3. #3
    Micron is online now Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    Code:
    Dim strbody, myemail, mypassword As String
    You got that from somewhere? It contains the classic error only setting the variable type of the last variable when declaring multiple variables on one line. Slight possibility that they intended strbody and myemail to be variants, but I doubt it. Only mypassword is a String; the rest are variants. Maybe

    Dim strbodyAs String, myemailAs String, mypassword As String

    is what it should be.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 6
    Last Post: 01-26-2017, 06:15 AM
  2. Send automatic email with form
    By matirob in forum Forms
    Replies: 1
    Last Post: 03-19-2016, 09:07 AM
  3. Send Emails from outlook
    By WhiskyLima in forum Access
    Replies: 8
    Last Post: 08-11-2014, 11:02 AM
  4. Automatic Emails
    By smit2215 in forum Queries
    Replies: 1
    Last Post: 03-10-2011, 01:23 PM
  5. Automatic emails.
    By motherboard in forum Queries
    Replies: 3
    Last Post: 05-04-2010, 11:03 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums