Results 1 to 4 of 4
  1. #1
    Kipandrews06 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Oct 2021
    Posts
    54

    How do you send an auto email without Outlook app having to be opened on users computer?

    Hi,


    I'm fairly new to access and still learning alot. I am making a "Maintenance Work Order Request" database for my company and on my form of the new work order I have programmed in a control button "Submit Order" to send an automatic email to the applicable maintenance department people. I have it working properly, but the problem I'm running into is that it wont send the email if the outlook app isn't opened on the users computer. Is there a way to still send the email without the user having to have their outlook opened up? My other question would be, I have written in the vba code to "SentOnBehalfofName" to make the emai "from" a dummy account "work_orders@company.com". This will be a shared database and probably up to 10 people will be able to get on and submit a work order. Will my "SentOnBehalf" email code still work on another users computer? Or will it only work from my computer? Any help would be greatly appreciated. Here is my current code:

    Code:
    Private Sub Enter_Record_Click()
    Dim oOutlook As Outlook.Application
    Dim oEmailItem As MailItem
    
    
    Set oOutlook = GetObject(, "Outlook.Application")
    If oOutlook Is Nothing Then
    Set oOutlook = New Outlook.Application
    End If
    Set oEmailItem = oOutlook.CreateItem(olMailItem)
    With oEmailItem
    End With
    'assign message to HMTL.body
    Body = oEmailItem.HTMLBody
    With oEmailItem
    
    
    .SentOnBehalfOfName = "Work_Orders@company.com"
    .To = "kip.andrews@company.com"
    .Subject = "New Work Order Submission"
    'Adding body text
    Dim mymsg As String
    mymsg = "A new work order request has been submitted and is ready for you to review!" & vbCrLf
    mymsg = mymsg & "Please login at your earliest convenience and update the order." & vbCrLf & vbCrLf
    mymsg = mymsg & "Sincerely," & vbCrLf & vbCrLf
    mymsg = mymsg & "WORCS_Admin" & vbCrLf
    mymsg = mymsg & "My Company"
    .Body = mymsg
    .Send
    
    
    End With
    Set oEmailItem = Nothing
    Set oOutlook = Nothing
    'DoCmd.OpenForm "WORCS_MsgBox", acNormal, "", "", , acNormal
    DoCmd.OpenForm "WORCS_MsgBox", acNormal, , , , acWindowNormal
    DoCmd.Close acForm, Me.Name
    
    
    End Sub

  2. #2
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,979
    Use CDO to send email direct from Access. No other email program is required.
    See this article and example app EMail Tester - Mendip Data Systems
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  3. #3
    Kipandrews06 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Oct 2021
    Posts
    54
    Thank you so much @isladogs for the help! Using the CDO method definitely solved my issue!

  4. #4
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,979
    Excellent. Glad to have helped
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

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

Similar Threads

  1. Replies: 4
    Last Post: 07-12-2018, 05:38 AM
  2. Send email using VBA and outlook
    By hinchi1 in forum Access
    Replies: 8
    Last Post: 10-17-2017, 12:11 PM
  3. Replies: 5
    Last Post: 09-14-2015, 07:24 AM
  4. How to Maximize outlook email when opened
    By kassem in forum Programming
    Replies: 2
    Last Post: 07-25-2014, 05:48 AM
  5. Send email from Access thru Outlook
    By ZMAN in forum Forms
    Replies: 2
    Last Post: 11-27-2010, 06:10 PM

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