Results 1 to 3 of 3
  1. #1
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,191

    Extracting Part of Mail Body

    Hi Guy's, can anyone correct this following function ? the MsgBox for Email Address is returning blank and the MsgBox for client is returning > from Website has been filled out < instead of the mail body ? the from Website has been filled is more like the subject or header, the txtClientMessage does have an enquiry in with name and email address etc from the GrabMail function

    Email grabbed and pasted works great.

    it is the ExtractMailBody that doesn't appear to grab correct data



    Code:
    Public Function GrabMail() As StringDim WordApp As Word.Application
    Dim MailBody As MailItem
    
    
    If TypeName(ActiveExplorer.Selection.Item(1)) = "MailItem" Then
    Set MailBody = ActiveExplorer.Selection.Item(1)
    MailBody.GetInspector().WordEditor.Range.FormattedText.Copy
    Forms!frmMainMenu!txtClientMessage = MailBody
    End If
    
    
    End Function

    Code:
    Public Function ExtractMailBody() As StringDim MailBody As String, EmailTbox As String
    Dim CLName() As String, EmailAdd() As String
    Dim a As Long, b As Long
    
    
    MailBody = Forms!frmMainMenu!txtClientMessage
    
    
    CLName = Split(MailBody, vbCrLf)
    For a = 0 To UBound(CLName)
    If InStr(1, CLName(a), "*Name:") > 0 Then
    Forms!frmMainMenu!txtClient = Mid(CLName(a), 7)
    End If
    MsgBox (Mid(CLName(a), 7))
    Next a
    
    
    EmailAdd = Split(MailBody, vbCrLf)
    For b = 0 To UBound(EmailAdd)
    If InStr(1, EmailAdd(b), "*Email Address:") > 0 Then
    EmailTbox = Mid(EmailAdd(b), 17)
    Forms!frmMainMenu!txtClient = EmailTbox
    End If
    MsgBox (EmailTbox)
    Next b
    
    
    End Function

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,722
    Dave,
    I don't use Outlook, but you may find some relevant code if you google with
    outlook vba to extract part of email body into Access


    I found this that may give you some ideas.

  3. #3
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,901
    I've never seen ActiveExplorer. Why use Word automation?

    I expect * wildcard is causing failure. Why are you using *? This causes InStr() to return 0 position - no string match.
    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.

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

Similar Threads

  1. image to mail body
    By DMT Dave in forum Access
    Replies: 17
    Last Post: 08-06-2019, 03:17 AM
  2. add bmp from word doc to mail body
    By DMT Dave in forum Access
    Replies: 1
    Last Post: 05-22-2018, 05:53 PM
  3. Extracting Part of a Field
    By The Professor in forum Queries
    Replies: 5
    Last Post: 10-08-2015, 10:03 AM
  4. Replies: 1
    Last Post: 05-27-2015, 08:57 AM
  5. Adding report content into e-mail Body
    By Toasty in forum Access
    Replies: 22
    Last Post: 08-01-2014, 11:56 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