Sending Text Message to Email: Subject and Body are Empty but Contents Stored in Attachment

Good afternoon,

I am using ImapClient, ImapMessageInfoCollection and MailMessage objects to retrieve email messages from 365. When I send a message from a mobile phone (iPhone or Android) to an email address, I’ve noticed that sometimes the message body is empty but the message contains an attachment that has the message body. If I use some existing non Aspose code to retrieve the email, the message body has the message. Is Aspose putting the message into an attachment or doing something with the body of the message? If so, is there a way to access just the message?

Hi,

Thank you for contacting Aspose Support team.

We have tested this issue at our end with the latest version of Aspose.Email for .NET 6.2.0 but were not able to reproduce the same while retrieving the messages from inbox using the API’s ImapClient. Aspose.Email API doesn’t include the body of the email message in the attachment in any case. Can you please make sure that you are using the latest version of the API? If possible, please share a test account credentials with us where such messages are available. We’ll use the API to retrieve the messages using the ImapClient and investigate the issue further at our end.

Hi,



Thanks for the response. I updated the version to 6.2 but still have the issue. I don’t have a test account that I can share but I can share the code so you can see what I’m doing.



I have attached two files, Aspose C#.txt, Aspose VB.txt. The C# sharp file is my email class without the connection info that I am using to retrieve the messages. Once I have the messages in a message collection (VB file), I loop through each message as ImapMessageInfo in MessageCollection (I am doing this because ImapMessageInfo does not have all of the message information) to get the unique ID. After I have the unique ID, I use that to fetch the message. Once I have the message, the body and subject fields are empty but there is an attachment that contains the message. This specifically happens when sent from a phone with AT&T as the service provider (text to email). I need the message text but do not want to get into checking attachments. My thought is that the message should be in the body. Can you look into that? Also, when sending text to email via T-Mobile, the body field is not empty but contains *.gif picture files (logo images). Does Aspose have a way to just get the message without the logo image files?



Do you have any sample code for how to retrieve an email message in 365 and read the subject and body?

Hi,

Thank you for sharing your feedback.

You can connect to Office 365 mailbox using the [IEWSClient](http://www.aspose.com/docs/display/emailnet/Connecting+to+Exchange+Server+using+WebDav+and+Exchange+Web+Service+%28EWS%29) of the API in addition to IMAP as shown in the following code sample.

Sample code:

const string mailboxUri = “https:[//outlook.office365.com/ews/exchange.asmx](https://outlook.office365.com/ews/exchange.asmx)”;
const string domain = @"";
const string username = @"username@companyname.onmicrosoft.com";
const string password = @“password”;
NetworkCredential credentials = new NetworkCredential(username, password, domain);
IEWSClient client = EWSClient.GetEWSClient(mailboxUri, credentials);
ExchangeMessageInfoCollection msgsColl = client.ListMessages(client.MailboxInfo.InboxUri);
//now traverse through messages collection and check each message for message body

Regarding your mentioned problems, it seems the issue is specific to emails from AT&T as service provider and it should be not like this. If this happens with messages from AT&T only, please send a few such sample messages to the following Office 365 account, so that we can fetch these at our end and investigate the issue further.

Account: [UserOne@AsposeFeb2016.onmicrosoft.com](mailto:UserOne@AsposeFeb2016.onmicrosoft.com)

Hi,



Thanks for your response.



(1) I’m not able to connect using the sample code. I am trying to connect to a 365 account with multiple mailboxes but haven’t had any success.



(2) If I send a text message (text not email) to our office 365 email address. When I get the message using Aspose it appears differently for each provider: (a) AT&T - the message is in an attachment and the body is empty. T-Mobile - the message with added images is in the body and the message itself is in an attachment. Sprint - the message is in the body with a signature “Sent from my mobile.” You should be able to send a message from an AT&T cell phone to your inbox and using the code I sent create the same issue. I’m wondering why this happens with Aspose because I can get just the message with no issues using IMAP4 but we are trying to implement Aspose.

Hi,

  1. Can you please try the following code that connects to an Office 365 Mailbox account and displays the number of messages in the Inbox? This is a test account so you can use it for sharing your feedback with us.

Sample Code:

IEWSClient client = EWSClient.GetEWSClient(“https://outlook.office365.com/ews/exchange.asmx”, "UserOne@AsposeFeb2016.onmicrosoft.com", “Aspose1234”);

Console.WriteLine(client.ListMessages(client.MailboxInfo.InboxUri).Count);
  1. We are sorry to share that there is no AT&T or T-Mobile service available at our end. Thus, if you can please arrange a test account on Office 365, configure it with Text-To-Outlook at your end and then send a text message to it for our reference, we’ll be able to investigate the issue further and assist you accordingly. We appreciate your cooperation in this regard.

(1) I think I’m connected to the mailbox and the count it 0. When I connect to our account I get the same count is 0. But that is connecting to the username on the account. This particular account has multiple mailboxes. The question I’m asking is, using the sample code you sent how do I connect to a specific mailbox within the user account? If I use the ImapClient I can specify “username/mailbox” as the username and connect to the mailbox. The problem here is that there is that, once I connect and get the message from the inbox there is no consistency with the location of the message body text; sometimes it’s in the body, other times it’s in htmlbody, htmlbodytext or in a text attachment. It’s also not just the message itself.





(2) Unfortunately, the messages sent from those providers already exist in an email account mailbox which is what is being used to work on this. I am not able to give out that information and I don’t have access to setup a test account. I also do not have either as a service provider.



I think this is an issue you all should look further into. As stated above, I am able to connect using ImapClient and can see the message parts as you have them broken down in your object but there is no consistency so something has to be happening in between. When someone sends a text to an email address, shouldn’t the message be in the .body field of your object?

Hi,

1. It means you can successfully connect to the Exchange server using the IEWSClient. Please note that you can not use the API’s ImapClient to access another user’s mailbox on the same account. However, this can be done using the IEWSClient interface as shown in the following code sample.

Sample Code:

// Create instance of EWSClient class by giving credentials
IEWSClient client = EWSClient.GetEWSClient(“https:[//outlook.office365.com/ews/exchange.asmx ](https://outlook.office365.com/ews/exchange.asmx)”, “testUser”, “pwd”, “domain”);

// Get Exchange mailbox info of other email account
ExchangeMailboxInfo mailboxInfo = client.GetMailboxInfo(”[otherUser@domain.com](mailto:otherUser@domain.com)”);

2. As alternative, can you please confirm if the same messages look fine when received in MS Outlook that is configured with the mailbox account? If so, please download these from MS Outlook locally to pc and provide such sample messages to us. We’ll append these to our Exchange server and try to reproduce the issue at our end for assisting you further.

Our API doesn’t break down received messages intentionally into what you have shared and this may related to some API feature malfunctioning that we need to investigate further. The received email details should be there in the body field of the message as expected. We are also trying to arrange such a test account that we can further use for investigating the matter at our end.

Is there a way we can send a text message to your test email account and have you look at the message and see if the message gives you the same issues we are experiencing? If so, what address do we send them to?

Hi,

You can try sending emails to the following test accounts for our further analysis.

  • asposeemail.test3@aspose.com
  • UserOne@AsposeFeb2016.onmicrosoft.com
  • UserTwo@AsposeFeb2016.onmicrosoft.com

I have gathered a few phones and sent messages from a few different devices and service providers. Here is the break-down of the messages:



A text to email message was sent from each device and service provider. The message body contains the service provider and the type of phone used to send the message.



1. Messages sent to asposeemail.test3@aspose.com, UserOne@AsposeFeb2016.onmicrosoft.com with only a message body



a. Message Body – AT&T, iPhone 6s

b. Message Body - T-Mobile, iPhone 6

c. Message Body - Sprint, iPhone 6

d. Message Body - Android Samsung Galaxy S6

e. Message Body - AT&T, Android

f. Message Body - Verizon, iPhone 6



2. A second batch of messages was sent to asposeemail.test3@aspose.com, UserOne@AsposeFeb2016.onmicrosoft.com with subject and message body



a. Subject – Test 1

Message – AT&T, iPhone 6s



b. Subject – Test 2

Message - T-Mobile, iPhone 6



c. Subject – Test 3

Message - Sprint, iPhone 6



d. Subject – Test 4

Message - Android Samsung Galaxy S6



e. Subject – Test 5

Message - AT&T, Android



f. Subject – Test 6

Message - Verizon, iPhone 6



The issue that we are having with using Aspose and Office 365 is that there is no consistency with how the message is parsed into the Aspose fields: for example, the message in 1.a. from AT&T doesn’t have any data in the body, htmlbody or htmlbodytext fields. The message is in the attachment. The message in 1.b. from T-Mobile has both a message body and attachment. The body also contains images before and after the message. The message in 1.c. from Sprint is in the body however the signature “Sent from Mobile” appears in front of the message.



Also, the Sprint messages do not have a time zone offset so there is no consistent way to determine the actual time but the AT&T messages do. We are in a different time zone from GMT, which appears to be the server’s time zone. Please advise.

Hi,

Thank you for sending the sample messages.

We have observed these at our end in MS Outlook as well as in browser and compared these to the messages downloaded using our Aspose.Email API. The behavior of our API is the same as that of the messages in browser as well as MS Outlook. MS Outlook shows the messages with attachments. You can observe the same by logging in to Office 365 with following credentials. Thus, it seems that the issue is not with the API but with the text messages sent to emails. Please observe the behavior at your end and share your feedback with us.

URL : outlook.office365.com
Username: UserOne@AsposeFeb2016.onmicrosoft.com
Password: Aspose1234

Good morning,

I was able to connect to the account using the information you provided and see the messages. Given there are multiple ways text to email messages appear to come through, do you have any recommendations as to the best way to handle getting the message body? Are there any plans on your end to look into how text to email messages are handled?

Hi John,

Thank you for sharing your feedback.

As mentioned earlier, the API has nothing wrong in this case and the issue resides at the message sending end. We could have investigated it further if the emails would have looked fine in MS Outlook or in web based email. Since these also show issue with the sent messages, we can not investigate the issue further at our end as the behavior of our API is the same as that of MS Outlook. Please let us know if we can be of any additional help to you in this regard.