Results 1 to 39 of 39

Thread: Outlook:Selecting an email, extract information from it

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jul 2005
    Posts
    18

    Outlook:Selecting an email, extract information from it

    Hi, I'm new to programming in Outlook. I've searched quite a few places to find out how to do this.

    I want to be able to retrieve information such as the name of the sender, the email body, etc. by selecting an email, then click on a button that I've created. I'm not sure how to refer to the selected email as well as referring to the specific fields of it. I would really appreciate if someone can point me in the right direction.

    Thanks in advance.

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Outlook:Selecting an email, extract information from it

    I have several Outlook code examples on these Forums.

    You will want to start with telling us how you added your "button"? Is it added in via an Add-In, Outlook VBA, VB6 automation, or VB.NET/C#, etc.

    An email is an Outlook.MailItem.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jul 2005
    Posts
    18

    Re: Outlook:Selecting an email, extract information from it

    hey RobDog, thanks for the quick reply

    I used Visual Studio VB to add the add-in. I found some code, can't remember where now, that adds a button and it's as follow:

    VB Code:
    1. Public Sub OnStartupComplete(ByRef custom As System.Array) Implements Extensibility.IDTExtensibility2.OnStartupComplete
    2.  
    3.         Dim oCommandBars As CommandBars
    4.         Dim oStandardBar As CommandBar
    5.  
    6.         On Error Resume Next
    7.         ' Set up a custom button on the "Standard" command bar.
    8.         oCommandBars = applicationObject.CommandBars
    9.         If oCommandBars Is Nothing Then
    10.             ' Outlook has the CommandBars collection on the Explorer object.
    11.             oCommandBars = applicationObject.ActiveExplorer.CommandBars
    12.         End If
    13.  
    14.         oStandardBar = oCommandBars.Item("Standard")
    15.         If oStandardBar Is Nothing Then
    16.             ' Access names its main toolbar Database.
    17.  
    18.             oStandardBar = oCommandBars.Item("Database")
    19.  
    20.         End If
    21.  
    22.         ' In case the button was not deleted, use the exiting one.
    23.         MyButton = oStandardBar.Controls.Item("New Opportunity")
    24.         If MyButton Is Nothing Then
    25.  
    26.             MyButton = oStandardBar.Controls.Add(1)
    27.             With MyButton
    28.                 .Caption = "New Opportunity"
    29.                 .Style = MsoButtonStyle.msoButtonCaption
    30.  
    31.                 ' The following items are optional, but recommended.
    32.                 ' The Tag property lets you quickly find the control
    33.                 ' and helps MSO keep track of it when more than
    34.                 ' one application window is visible. The property is required
    35.                 ' by some Office applications and should be provided.
    36.  
    37.                 .Tag = "New Opportunity"
    38.  
    39.                 ' The OnAction property is optional but recommended.
    40.                 ' It should be set to the ProgID of the add-in, so that if
    41.                 ' the add-in is not loaded when a user clicks the button,
    42.                 ' MSO loads the add-in automatically and then raises
    43.                 ' the Click event for the add-in to handle.
    44.  
    45.                 .OnAction = "!<MyCOMAddin.Connect>"
    46.  
    47.                 .Visible = True
    48.             End With
    49.         End If
    50.  
    51.         ' Display a simple message to show which application you started in.
    52.         'MsgBox("Started in " & applicationObject.Name & ".")
    53.  
    54.  
    55.         oStandardBar = Nothing
    56.         oCommandBars = Nothing
    57.  
    58.  
    59.     End Sub

    Also, I've found a function that returns the sender's address. But it takes an Outlook.Mailitem as an input. How can I pass the mail that's been selected by the user?

    VB Code:
    1. Function GetMailItemSenderAddress(ByVal oOutlookMail As Outlook.MailItem) As String
    2.         Dim oMapiMessage As Object      'MAPI.Message
    3.         Dim oSession As Object          'MAPI.Session
    4.         Dim sEntryID As String
    5.         '      Dim sEntryID As String
    6.  
    7.         MsgBox(oOutlookMail)
    8.  
    9.         oSession = CreateObject("MAPI.Session")
    10.         'Logon to the existing session
    11.         oSession.Logon("", "", False, False)
    12.         'Get the message Information
    13.         sEntryID = oOutlookMail.EntryID
    14.         sEntryID = oOutlookMail.Parent.StoreID
    15.         'Get the message
    16.         oMapiMessage = oSession.GetMessage(sEntryID, sEntryID)
    17.         'Extract the Sender's Address and Return value
    18.         GetMailItemSenderAddress = oMapiMessage.Sender.Address
    19.  
    20.         oSession.Logoff()
    21.         oSession = Nothing
    22.         oMapiMessage = Nothing
    23.  
    24.         Exit Function
    25.  
    26. ErrFailed:
    27.         ' Debug.Print(Err.Description)
    28.         Debug.Assert(False)
    29.         GetMailItemSenderAddress = ""
    30.     End Function

  4. #4
    Fanatic Member dannymking's Avatar
    Join Date
    Jul 2005
    Location
    Darlington, North East UK
    Posts
    677

    Re: Outlook:Selecting an email, extract information from it

    You don't need the MailItem to do this..

    Here is some sample code that I have

    VB Code:
    1. Dim myOlExp As Explorer
    2.   Dim myOlSel As Selection
    3.   Dim myOlMail As MailItem
    4.   Dim i As Integer, j As Long
    5.   Set myOlExp = ActiveExplorer
    6.   Set myOlSel = myOlExp.Selection
    7.   For j = 1 To myOlSel.Count
    8.     Set myOlMail = myOlSel.Item(j)
    9.     MsgBox myOlMail.Subject
    10.     MsgBox myOlMail.Sender
    11.     Set myOlMail = Nothing
    12.   Next j
    13.   Set myOlSel = Nothing
    14.   Set myOlExp = Nothing

    It picks up the selected email and get's both the subject and the sender
    Danny

    Never Think Impossible

    If you find my answer helpful then please add to my reputation

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Jul 2005
    Posts
    18

    Re: Outlook:Selecting an email, extract information from it

    Hey Danny,

    On the line: myOlExp = ActiveExplorer
    It says ActiveExplorer is not declared. The other three variables I've added 'Outlook.' in front of them and they seem to be fine. How can I fix that line?

  6. #6
    Fanatic Member dannymking's Avatar
    Join Date
    Jul 2005
    Location
    Darlington, North East UK
    Posts
    677

    Re: Outlook:Selecting an email, extract information from it

    VB Code:
    1. Dim myOlApp As Outlook.Application
    2.   Dim myOlExp As Outlook.Explorers
    3.   Dim obSi As Outlook.Selection
    4.   Dim obMi As Outlook.MailItem
    5.   Set myOlApp = GetObject(,"Outlook.Application")
    6.   Set myOlExp = myOlApp.Explorers
    7.   Set obSi = myOlExp.Item(1).Selection
    8.   For i = 1 To obSi.Count
    9.     Set obMi = obSi.Item(i)
    10.     Debug.Print obMi.SenderName
    11.     Debug.Print obMi.Subject
    12.   Next i
    13.   Set obMi = Nothing
    14.   Set obSi = Nothing
    15.   Set myOlExp = Nothing
    16.   Set myOlApp = Nothing

    Try that one
    Last edited by dannymking; Jul 29th, 2005 at 09:31 AM. Reason: Corrected Code
    Danny

    Never Think Impossible

    If you find my answer helpful then please add to my reputation

  7. #7

    Thread Starter
    Junior Member
    Join Date
    Jul 2005
    Posts
    18

    Re: Outlook:Selecting an email, extract information from it

    What do I declare obMi, obSi, obEx and obOt as?

  8. #8
    Fanatic Member dannymking's Avatar
    Join Date
    Jul 2005
    Location
    Darlington, North East UK
    Posts
    677

    Re: Outlook:Selecting an email, extract information from it

    Sorry.. Copy and paste error.. will fix it in the original
    Danny

    Never Think Impossible

    If you find my answer helpful then please add to my reputation

  9. #9

    Thread Starter
    Junior Member
    Join Date
    Jul 2005
    Posts
    18

    Re: Outlook:Selecting an email, extract information from it

    It works!
    Thanks!

    I have a few more questions though. Where can I look for documentations on other fields? Specifically the body of the email, date, etc.?
    When I first access that code, there's a pop up that asks if I'm going to allow the program to access my email. Is it possible to get rid of that somehow? May be not by code but through registry?

    Another question, which is an entirely different topic, how persistent are class variables? I have a public class variable in my form that I would like to be accessible in other classes such as Connect, through out the instance of Outlook. How can I achieve that?

  10. #10
    Fanatic Member dannymking's Avatar
    Join Date
    Jul 2005
    Location
    Darlington, North East UK
    Posts
    677

    Re: Outlook:Selecting an email, extract information from it

    Because you have declared obMi As Outlook.MailItem you can scroll through the remainder of a mail item's properties by pressing .

    The pop up message is outlook security Perform a search for ClickYes, this is program that will continue to scan for messages like this and click's the yes button for you. There are other methods which does include changing the registry.

    To allow a variable to be available throughout your whole project declare it as a global variable in module (or Public if you prefer)
    Danny

    Never Think Impossible

    If you find my answer helpful then please add to my reputation

  11. #11

    Thread Starter
    Junior Member
    Join Date
    Jul 2005
    Posts
    18

    Re: Outlook:Selecting an email, extract information from it

    Since I'm creating an add-in, would the global variable be in the Connect class? I tried to declare the global variable in the form but I suppose the value of the variable is re-initialized everytime the form is loaded.

    How can I declare the variable in Connect and be able to use it in the form as well? It wouldn't let me do Connect.globalvar. I've also tried defining an object for connect then go objConnect.globalvar and that crashes.

  12. #12
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Outlook:Selecting an email, extract information from it

    Quote Originally Posted by dannymking
    You don't need the MailItem to do this..
    But you are using the MailItem.
    VB Code:
    1. Dim obMi As Outlook.MailItem
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  13. #13
    Fanatic Member dannymking's Avatar
    Join Date
    Jul 2005
    Location
    Darlington, North East UK
    Posts
    677

    Re: Outlook:Selecting an email, extract information from it

    That's Just Picking on me

    In fact you don't need the mail item.. it is easier with it though..

    VB Code:
    1. Dim myOlApp As Outlook.Application
    2.   Dim myOlExp As Outlook.Explorers
    3.   Dim obSi As Outlook.Selection
    4.   Set myOlApp = GetObject(,"Outlook.Application")
    5.   Set myOlExp = myOlApp.Explorers
    6.   Set obSi = myOlExp.Item(1).Selection
    7.   For i = 1 To obSi.Count
    8.     Debug.Print obSi.Item(i).SenderName
    9.     Debug.Print obSi.Item(i).Subject
    10.   Next i
    11.   Set obSi = Nothing
    12.   Set myOlExp = Nothing
    13.   Set myOlApp = Nothing
    Danny

    Never Think Impossible

    If you find my answer helpful then please add to my reputation

  14. #14

    Thread Starter
    Junior Member
    Join Date
    Jul 2005
    Posts
    18

    Re: Outlook:Selecting an email, extract information from it

    hey guys...referring to my post , what should I do about global variable?

    Danny, your code was working fine but I don't know what's wrong now.
    VB Code:
    1. Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
    2.         Dim myOlApp As Outlook.Application
    3.         Dim myOlExp As Outlook.Explorers
    4.         Dim obSi As Outlook.Selection
    5.         Dim obMi As Outlook.MailItem
    6.         Dim i As Integer
    7.  
    8.         MsgBox("1")
    9.  
    10.         myOlApp = GetObject(, "Outlook.Application")
    11.  
    12.         MsgBox("2")
    13.  
    14.         myOlExp = myOlApp.Explorers
    15.  
    16.         MsgBox("3")
    17.  
    18.         obSi = myOlExp.Item(1).Selection
    19.         MsgBox("about if")
    20.         If obSi.Count > 0 Then
    21.             MsgBox("in if")
    22.             For i = 1 To obSi.Count
    23.                 obMi = obSi.Item(i)
    24.                 MsgBox(obMi.SenderName)
    25.                 MsgBox(obMi.Body)
    26.             Next i
    27.             obMi = Nothing
    28.             obSi = Nothing
    29.             myOlExp = Nothing
    30.             myOlApp = Nothing
    31.         Else
    32.             MsgBox("in else")
    33.             MsgBox("Please select an email.")
    34.         End If
    35.  
    36.  
    37.         Me.Close()
    38.     End Sub

    It crashes after msgbox 1 pops up. Any idea?

  15. #15
    Fanatic Member dannymking's Avatar
    Join Date
    Jul 2005
    Location
    Darlington, North East UK
    Posts
    677

    Re: Outlook:Selecting an email, extract information from it

    This is actually inside Outlook? or some other office app?
    Danny

    Never Think Impossible

    If you find my answer helpful then please add to my reputation

  16. #16

    Thread Starter
    Junior Member
    Join Date
    Jul 2005
    Posts
    18

    Re: Outlook:Selecting an email, extract information from it

    It's used in Outlook, developed in Visual Studio.

  17. #17
    Fanatic Member dannymking's Avatar
    Join Date
    Jul 2005
    Location
    Darlington, North East UK
    Posts
    677

    Re: Outlook:Selecting an email, extract information from it

    Ok the code is actually from Access...

    The line that is causing the problem is the attempt to GetObject if outlook is not open then this will cause a problem.

    If the code is inside Outlook you should be able to drop the outlook part of it... like so

    VB Code:
    1. Dim myOlExp As Explorers
    2.   Dim obSi As Selection
    3.   Dim obMi As MailItem
    4.   Set myOlExp = Application.Explorers
    5.   Set obSi = myOlExp.Item(1).Selection
    6.   For i = 1 To obSi.Count
    7.     Set obMi = obSi.Item(i)
    8.     Debug.Print obMi.SenderName
    9.     Debug.Print obMi.Subject
    10.   Next i
    11.   Set obMi = Nothing
    12.   Set obSi = Nothing
    13.   Set myOlExp = Nothing

    In my corporation VBA is disabled behind Outlook so I cannot test to see if this will actually work
    Danny

    Never Think Impossible

    If you find my answer helpful then please add to my reputation

  18. #18

    Thread Starter
    Junior Member
    Join Date
    Jul 2005
    Posts
    18

    Re: Outlook:Selecting an email, extract information from it

    The code wouldn't be used if Outlook is not opened though. I just kept getting the follow msg when it crashes:

    Object reference not set to an instance of an object.

    Also when I tried the code you provided above, I'm not sure what to set Application as....

  19. #19
    Fanatic Member dannymking's Avatar
    Join Date
    Jul 2005
    Location
    Darlington, North East UK
    Posts
    677

    Re: Outlook:Selecting an email, extract information from it

    You do not need to set Application to anything.. It refers to the Application to which the code resides..
    Danny

    Never Think Impossible

    If you find my answer helpful then please add to my reputation

  20. #20
    Fanatic Member dannymking's Avatar
    Join Date
    Jul 2005
    Location
    Darlington, North East UK
    Posts
    677

    Re: Outlook:Selecting an email, extract information from it

    Looking back over your code you are using .Net to build this.. in testing it will attempt to GetObject of Outlook..

    If Outlook is not open then it will fail.. you will need to CreateObject instead.

    VB Code:
    1. myOlApp = CreateObject("Outlook.Application")
    Danny

    Never Think Impossible

    If you find my answer helpful then please add to my reputation

  21. #21
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Outlook:Selecting an email, extract information from it

    plui31, you are writting this in .NET. Which version and it appears to be automating Outlook and not actually in VBA.
    Your attaching your variable object to the .NET Application object and not Outlooks?

    Missed that one Danny
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  22. #22

    Thread Starter
    Junior Member
    Join Date
    Jul 2005
    Posts
    18

    Re: Outlook:Selecting an email, extract information from it

    Quote Originally Posted by dannymking
    Looking back over your code you are using .Net to build this.. in testing it will attempt to GetObject of Outlook..

    If Outlook is not open then it will fail.. you will need to CreateObject instead.

    VB Code:
    1. myOlApp = CreateObject("Outlook.Application")
    I'm testing it by opening up Outlook manually then click on the button I've added. Should I have CreateObject anyway?

  23. #23

    Thread Starter
    Junior Member
    Join Date
    Jul 2005
    Posts
    18

    Re: Outlook:Selecting an email, extract information from it

    I'm using Microsoft Visual Studio .NET 2003.

    Quote Originally Posted by RobDog888
    Your attaching your variable object to the .NET Application object and not Outlooks?
    I'm not sure what you're asking here

  24. #24
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Outlook:Selecting an email, extract information from it

    In VB.NET there is an Application object and also in Outlook. Since there was code like this...
    VB Code:
    1. Set myOlExp = Application.Explorers
    VB doesnt know which your referring to. Now however your current code is , it needs to make the distinction between the two by using the myOlApp object variable being set to the Outlook.Application instance.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  25. #25

    Thread Starter
    Junior Member
    Join Date
    Jul 2005
    Posts
    18

    Re: Outlook:Selecting an email, extract information from it

    aah okay. thanks It's working now.

    I have a question about the body of the Outlook message. How is a newline represented? I want to replace every newline with a special character. How can I do that?

  26. #26
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Outlook:Selecting an email, extract information from it

    The new line character is ...
    vbNewLine
    Chr(13) & Chr(10)
    vbCrLf

    You can replace a new line with your own character by using the Replace function.

    VB Code:
    1. strBody = Replace(strBody, vbNewLine, "NL") 'Or ??? character instead of "NL"
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  27. #27

    Thread Starter
    Junior Member
    Join Date
    Jul 2005
    Posts
    18

    Re: Outlook:Selecting an email, extract information from it

    hey RobDog

    I've tired the following:

    VB Code:
    1. iBody = Replace(iBody, vbNewLine, "%0a")
    2.                 iBody = Replace(iBody, Chr(13) & Chr(10), "%0a")
    3.                 iBody = Replace(iBody, vbCrLf, "%0a")

    And I also have this: Replace(iBody, " ", "%20")

    I sent myself an email that looks like this:

    first line

    second line


    And after the replace, it merges the string into first%20linesecond%20line.
    What's the problem?

  28. #28
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Outlook:Selecting an email, extract information from it

    Nothing. Your taking out the newlines so you end up with a string with your substitute char as the line breaks but since its not a line break it wont break.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  29. #29

    Thread Starter
    Junior Member
    Join Date
    Jul 2005
    Posts
    18

    Re: Outlook:Selecting an email, extract information from it

    True...but how come my substitute character, "%0a", isn't there?

  30. #30
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Outlook:Selecting an email, extract information from it

    What char does "%0a" represent? I know its supposed to be a web thing, right?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  31. #31

    Thread Starter
    Junior Member
    Join Date
    Jul 2005
    Posts
    18

    Re: Outlook:Selecting an email, extract information from it

    Yeah, it's suppose to be a newline for forms and %20 is a space. Any idea how to get it to work?

  32. #32
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Outlook:Selecting an email, extract information from it

    What is the version of Outlook and what is the .BodyFormat of the email?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  33. #33

    Thread Starter
    Junior Member
    Join Date
    Jul 2005
    Posts
    18

    Re: Outlook:Selecting an email, extract information from it

    It's Outlook 2000.
    I'm not sure what .BodyFormat is...

    This is weird. I changed my code to:
    iBody = Replace(iBody, vbNewLine, "xxx")

    and it was fine. It got it right. But when it's "%0a", It just merges together...

  34. #34
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Outlook:Selecting an email, extract information from it

    Will the newline work if its not in a form?

    .BodyFormat is only available in Outlook 2002+

    You may want to use the .HTMLBody to display your body text in HTML. Your special chars should work correctly in that format.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  35. #35

    Thread Starter
    Junior Member
    Join Date
    Jul 2005
    Posts
    18

    Re: Outlook:Selecting an email, extract information from it

    Quote Originally Posted by RobDog888
    Will the newline work if its not in a form?
    I think as long as it's a textbox then it should work.

    Quote Originally Posted by RobDog888

    .BodyFormat is only available in Outlook 2002+

    You may want to use the .HTMLBody to display your body text in HTML. Your special chars should work correctly in that format.
    How do I do that?

  36. #36
    Fanatic Member dannymking's Avatar
    Join Date
    Jul 2005
    Location
    Darlington, North East UK
    Posts
    677

    Re: Outlook:Selecting an email, extract information from it

    You can't it's only available in 2002 and you are using 2000
    Danny

    Never Think Impossible

    If you find my answer helpful then please add to my reputation

  37. #37
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Outlook:Selecting an email, extract information from it

    Quote Originally Posted by dannymking
    You can't it's only available in 2002 and you are using 2000
    What U talk'n bot willis?

    The .HTMLBody is available in Outlook 2000.

    Here is the specifics on the HTMLBody property in Outlook 2000.

    http://msdn.microsoft.com/library/de...roHTMLBody.asp
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  38. #38
    Fanatic Member dannymking's Avatar
    Join Date
    Jul 2005
    Location
    Darlington, North East UK
    Posts
    677

    Re: Outlook:Selecting an email, extract information from it

    mis-read.. though he was talking about .bodyformat
    Danny

    Never Think Impossible

    If you find my answer helpful then please add to my reputation

  39. #39

    Thread Starter
    Junior Member
    Join Date
    Jul 2005
    Posts
    18

    Re: Outlook:Selecting an email, extract information from it

    aaah alright. I'll look into it.

    Thanks for all your help, Danny & RobDog!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width