Results 1 to 4 of 4
  1. #1
    lonesoac0 is offline Advanced Beginner
    Windows 7 32bit Access 2013
    Join Date
    Aug 2014
    Posts
    36

    Send a plain text message without any prompt

    Hello all,

    I know I found a method to send a plain text message yesterday but cannot find it again. I am currently using the SendObject method but that still gives me a prompt to send it. The below code holds some promise, but it still shows the email message and then sends it. I know that I found a send email method where it was just plain text and did not prompt me for anything, it just sent. That is what I am look for. *Should have saved it when I had it*. lol

    Code:
    Dim olApp As outlook.Application
    Dim objNS As Outlook.Namespace
    Dim objMail As Outlook.MailItem
    Dim objSentItems As Outlook.MAPIFolder
    Dim myInspector As Outlook.Inspector
    
    'Check whether outlook is open, if it is use get object, if not use create object
    On Error Resume Next
    Set olApp = GetObject(, "Outlook.Application")
    On Error GoTo 0
    If olApp Is Nothing Then
        Set olApp = CreateObject("Outlook.Application")
    End If
    
    Set objNS = olApp.GetNamespace("MAPI")
    objNS.Logon
    
    'Prepare the mail object    
    Set objMail = olApp.CreateItem(olMailItem)
    
    With objMail
    .To = <insert recipients name as string>
    .Subject = <insert subject as string>
    .Body = <insert message as string>
    .Display   
    End With
    
    'Give outlook some time to display the message    
    Application.Wait (Now + TimeValue("0:00:05"))
    
    'Get a reference the inspector obj (the window the mail item is displayed in)
    Set myInspector = objMail.GetInspector
    
    'Activate the window that the mail item is in and use sendkeys to send the message
    myInspector.Activate
    SendKeys "%s", True


  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,825
    If you don't want to display then remove or comment the .Display and lines that follow the End With.

    Then use .Send in the With block.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Micron is offline Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    Rather than use SendKeys...??
    Code:
    With objMail
    .To = <insert recipients name as string>
    .Subject = <insert subject as string>
    .Body = <insert message as string>
    .Send 
    End With
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  4. #4
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,016
    Quote Originally Posted by Micron View Post

    ...Rather than use SendKeys...??
    Good idea! Per Allen Browne, from v2007 forward

    Quote Originally Posted by Allen Browne

    Unless previous versions of Access are also installed, macros that use Sendkeys may fail, with the message: The SendKeys action requires the Microsoft Office Access Utility Add-in to be loaded...
    and I've seen subsequent reports indicating that

    • The may fail part is to be taken as written...it may fail or it may not fail...there is no consistency!
    • The bug applies to SendKeys when used in code as well as in Macros.

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

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

Similar Threads

  1. Copy and paste plain text.
    By 316854 in forum Access
    Replies: 9
    Last Post: 12-14-2015, 09:16 PM
  2. Replies: 1
    Last Post: 09-01-2015, 01:06 PM
  3. HTML characters in plain text field
    By etorasso in forum Access
    Replies: 3
    Last Post: 09-25-2014, 11:47 AM
  4. How to put a prompt message inside a text box
    By usmcgrunt in forum Forms
    Replies: 3
    Last Post: 11-05-2010, 09:55 AM
  5. Convert rtf to plain text
    By techneophyte in forum Programming
    Replies: 0
    Last Post: 09-08-2010, 11:13 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