Tips for extracting recipients from an email

When using Outlook.Interop to extract the Html Body from received emails, I am encountering an issue where I can only retrieve the names of recipients and not their full email addresses.

 Application myApp = new ApplicationClass();
            NameSpace mapiNameSpace = myApp.GetNamespace("MAPI");
            MAPIFolder myInbox = mapiNameSpace.GetDefaultFolder(OlDefaultFolders.olFolderInbox).Folders["digitel"];

            List<MailItem> ReceivedEmails = new List<MailItem>();
            
            foreach (MailItem mail in myInbox.Items)
            { ReceivedEmails.Add(mail); }

            var Recipients = ReceivedEmails[0].Recipients.ToString();
            

Answer №1

Take a look at this snippet:

for each (Outlook.Recipient recipient in ReceivedEmails[0].Recipients)
{
    Debug.WriteLine(recipient.AddressEntry.GetExchangeUser().PrimarySmtpAddress.ToSt‌​‌​ring());
}

If you encounter any issues, feel free to reach out!

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Is there a way to serialize a C# object to JSON while maintaining the namespace?

The main class includes a property that is replaced by a new property with a different type in the subclass. This has caused an issue during deserialization. I am unable to change the property name in C# or JSON, but I can potentially add a namespace. nam ...

"Restoring" a JSON data string in a WebForms application through a WEB API endpoint

I have successfully integrated Web API services into my ASP.NET WebForms application to retrieve data using GET requests. Now I need to update an object using a PUT request by sending a JSON string that should be mapped to a defined model/class and receive ...

Automatically trigger the Submit button click with this selector

I'm having trouble automating the clicking of a 'Submit' button that only becomes clickable after a specific action is taken. In this case, the user needs to click the TOS checkbox before the button can be clicked. I've been unable to f ...

Exploring the internet with selenium

I'm currently facing difficulties navigating a website for information scraping with Selenium. The issue lies in the site's use of ng-click to update a table, requiring me to activate different tabs on the page in order to access the desired data ...

Sending the "Enter Key" using JavaScript in Selenium can be achieved by utilizing the "executeScript" function

I'm currently developing an automation flow using IE 11 with Selenium and Java. On a particular web page, I need to input a value in a Text Box and then press Enter. I have successfully managed to input the values using the following code: // The &ap ...

How to retrieve text from the <td> element with Selenium

Currently, I am trying to extract the value enclosed within the <td> tag containing 30.0000 from a table using Selenium. However, every time I attempt to retrieve it, I receive 0.0000 instead. The method I have used so far is findElementByXPath(".//* ...

Using Selenium WebDriver to Extract Variables from JavaScript SourceCode

Currently, I am dealing with a web page source code that utilizes JavaScript to display text. Below is an excerpt from the source: var display_session = get_cookie("LastMRH_Session"); if(null != display_session) { document.getElementById("sessionDIV") ...

Selenium is having trouble locating the specified tag

Why is the Python code unable to find the <video> tag for this specific URL? The Chrome dev tools show that the tag exists. I've tried various waits but have had no luck. from selenium import webdriver from selenium.webdriver.common.by import B ...

Having difficulty retrieving the values from the 'App.config' file within the Unit testing project using Nunit

In my 'nunit' project created in Visual Studio, I have a simple test but no default 'App.config' file. Therefore, I manually created an 'App.config' file and marked it 'Copy always' from the properties option. When ...

Looking to streamline your testing process by focusing solely on the desired test cases?

Our project currently has 200 test cases, however executing all of them is challenging. We are looking to run only a subset of these tests, specifically between 150 and 156. How can we achieve this in Selenium? Is it possible, and if so, how should we go ...

Tips for excluding text from `<script>` tags in the HTML DOM when using the `element.getText()` method

Currently, I am utilizing Selenium with Java to conduct tests on an HTML page. To illustrate, here is a snippet of HTML code: <a> Return to homepage <script> <form>...</form> </script> </a> My main objective ...

Error in locating element using CSS selector with Selenium in Python: Invalid Selector Exception

I'm currently working on a Python3 web bot using selenium-webdriver, but I don't have much experience with Selenium. I've encountered an issue where I am receiving the exception "selenium.common.exceptions.InvalidSelectorException: Message: ...

Selenium error: Element is unclickable due to ElementClickInterceptedException

Although I have examined several similar questions that address the issue, such as Debugging "Element is not clickable at point" error , Selenium Webdriver - element not clickable error in firefox, ElementClickInterceptedException: Message: Eleme ...

Is there a library available that can assist me in writing JavaScript code within C#?

Currently, I am in search of a tool that can assist me in writing C# code that will automatically convert to JavaScript. The main benefits I am seeking are improved code-completion and type-safety. Specifically, I am interested in the following features: ...

Error: The 'geckodriver' executable must be located within the PATH directory

Recently, I encountered an issue while trying to deploy a Flask app on a production server using Firefox Geckodriver. The server runs on Ubuntu 18.04 with nginx installed and the application itself is a image detection Flask Python program. Oddly enough, t ...

I am looking to extract the key value as a string and the values as a double. Please note that the values may need to be converted to a double by removing the percentage sign

Here is the core code snippet of my base class. I need to extract key values as strings and value values as doubles in order to compare them with a specified range in the verifier tool. Please note that we are removing the % sign from the double values b ...

Selenium error: Element not found within iframe troubleshooting

When attempting to run a selenium script for automated testing on servicenow, I encountered an issue where an element was not found when trying to populate a field within the webpage. The login page contains an iframe, but after logging in, it seems that t ...

Interacting with a WCF service using jQuery

Recently, I have been attempting to utilize a JSON file to consume a WCF service. My goal is to extract values from a basic HTML form and then pass those values into an object instantiated in the WCF using JSON. Despite my best efforts, I have not been suc ...

Python allows for the retrieval of the aria-label attribute as text based on the div id with the help of libraries like Beautiful Soup

<div id="i19" class="quantumWizTogglePapercheckboxEl appsMaterialWizTogglePapercheckboxCheckbox docssharedWizToggleLabeledControl freebirdThemedCheckbox freebirdThemedCheckboxDarkerDisabled freebirdMaterialWidgetsToggleLabeledCheckbox isC ...

Creating a JSON response

Currently, I am developing a self-hosted REST API for monitoring the status of multiple servers. The task at hand requires me to return a simple response when everything is running smoothly: {"response":"ok"} However, in case of an error on any queried ...