Extract MSG Metadata via C++
Build your own C++ apps to add, edit, remove or extract metadata from MSG files using server-side APIs.
How to Get MSG Metadata Using C++
In order to extract MSG metadata, we’ll use
API which is a feature-rich, powerful and easy to use document metadata extraction API for C++ platform. You can download its latest version directly, just open
package manager, search for Aspose.Email.Cpp and install. You may also use the following command from the Package Manager Console.
Command
PM> Install-Package Aspose.Email.Cpp
Steps to Extract Metadata of MSG via C++
Get the type of the message while using GetProperties which in turn allows getting all metadata information via a simple loop.
- Load the MSG file via MapiMessage::FromFile
- Get properties collection using get_Properties()
- Get the respective property using idx_get
System Requirements
Aspose.Email for C++ supports on all major platforms and Operating Systems. Please make sure that you have the following prerequisites.
- Microsoft Windows or a compatible OS with C++ Runtime Environment for Windows 32 bit, Windows 64 bit and Linux 64 bit.
- Aspose.Email for C++ DLL referenced in your project.
Extract Metadata of MSG - C++
// Load from file
System::SharedPtr<MapiMessage> msg = MapiMessage::FromFile(dataDir + L"message.msg");
System::String subject;
// Access the MapiPropertyTag.PR_SUBJECT property
System::SharedPtr<MapiProperty> prop = msg->get_Properties()->idx_get(MapiPropertyTag::PR_SUBJECT);
// If the property is not found, check the MapiPropertyTag.PR_SUBJECT_W (which is a // Unicode peer of the MapiPropertyTag.PR_SUBJECT)
if (prop == nullptr){
prop = msg->get_Properties()->idx_get(MapiPropertyTag::PR_SUBJECT_W);
}
// Cannot found
if (prop == nullptr){
System::Console::WriteLine(L"No property found!");
return;
}
// Get the property data as string
subject = prop->GetString();
System::Console::WriteLine(System::String(L"Subject:") + subject);
// Read internet code page property
prop = msg->get_Properties()->idx_get(MapiPropertyTag::PR_INTERNET_CPID);
if (prop != nullptr){
System::Console::WriteLine(System::String(L"CodePage:") + prop->GetLong());
}
About Aspose.Email for C++ API
Aspose.Email is a Microsoft Outlook and Thunderbird formats parsing solution. One can easily create, manipulate, convert email and storage formats such as MSG, EMLX, EML and MHT. Handling of email attachments, customization of message headers and implementation of different network protocols like POP3, IMAP & SMTP to send & receive emails is much easier. Its a standalone API and does not require Microsoft Outlook or any other software installation.Extract Metadata of MSG via Online App
View & edit Metadata to MSG documents by using our Live Demos with following benefits.
MSG What is MSG File Format
MSG is a file format used by Microsoft Outlook and Exchange to store email messages, contact, appointment, or other tasks. Such messages may contain one or more email fields, with the sender, recipient, subject, date, and message body, or contact information, appointment particulars, and one or more task specifications. The properties that constitute the Message object, including are also a part of the MSG file. MSG file has headers, main message body, and hyperlinks as plain ASCII text. MSG files are also suitable with the programs that need Microsoft's Messaging Applications Programming Interface (MAPI).
Read More