independetsoft.msg
Microsoft Outlook .msg file module for Python. Use this module to easy create, read, update and parse Outlook message files.
Features
Create message, appointment, task, contact or any other Outlook item.
Read any Outlook .msg file and get all properties.
Convert from Outlook message (.msg file) to MIME message (.eml file)
Convert from MIME message (.eml file) to Outlook message (.msg file)
Set/Get MAPI properties.
Set/Get named properties.
Add attachments.
Read attachments.
Save attachments.
Add embedded messages.
Read embedded messages.
Save embedded messages.
Examples
**********************************************************************************************************************************
Create message with plain text body, set some properties and recipients.
**********************************************************************************************************************************
from independentsoft.msg import Message
from independentsoft.msg import Recipient
from independentsoft.msg import ObjectType
from independentsoft.msg import DisplayType
from independentsoft.msg import RecipientType
from independentsoft.msg import MessageFlag
from independentsoft.msg import StoreSupportMask
message = Message()
recipient1 = Recipient()
recipient1.address_type = "SMTP"
recipient1.display_type = DisplayType.MAIL_USER
recipient1.object_type = ObjectType.MAIL_USER
recipient1.display_name = "John Smith"
recipient1.email_address = "John@domain.com"
recipient1.recipient_type = RecipientType.TO
recipient2 = Recipient()
recipient2.address_type = "SMTP"
recipient2.display_type = DisplayType.MAIL_USER
recipient2.object_type = ObjectType.MAIL_USER
recipient2.display_name = "Mary Smith"
recipient2.email_address = "Mary@domain.com"
recipient2.recipient_type = RecipientType.CC
message.subject = "Test"
message.body = "Body text"
message.display_to = "John Smith"
message.display_cc = "Mary Smith"
message.recipients.append(recipient1)
message.recipients.append(recipient2)
message.message_flags.append(MessageFlag.UNSENT)
message.store_support_masks.append(StoreSupportMask.CREATE)
message.save("e:\\output.msg")
**********************************************************************************************************************************
Create message with HTML and RTF body. Outlook requires RTF body to be set if HTML is present in order to display rich body text.
**********************************************************************************************************************************
from independentsoft.msg import Message
from independentsoft.msg import Recipient
from independentsoft.msg import ObjectType
from independentsoft.msg import DisplayType
from independentsoft.msg import RecipientType
from independentsoft.msg import MessageFlag
from independentsoft.msg import StoreSupportMask
message = Message()
recipient1 = Recipient()
recipient1.address_type = "SMTP"
recipient1.display_type = DisplayType.MAIL_USER
recipient1.object_type = ObjectType.MAIL_USER
recipient1.display_name = "John Smith"
recipient1.email_address = "John@domain.com"
recipient1.recipient_type = RecipientType.TO
recipient2 = Recipient()
recipient2.address_type = "SMTP"
recipient2.display_type = DisplayType.MAIL_USER
recipient2.object_type = ObjectType.MAIL_USER
recipient2.display_name = "Mary Smith"
recipient2.email_address = "Mary@domain.com"
recipient2.recipient_type = RecipientType.CC
html_body = "<html><body><b>Hello World bold html text</b></body></html>"
html_body_with_rtf = "{\\rtf1\\ansi\\ansicpg1252\\fromhtml1 \\htmlrtf0 " + html_body + "}"
rtf_body = html_body_with_rtf.encode("utf_8")
message.subject = "Test"
message.display_to = "John Smith"
message.display_cc = "Mary Smith"
message.recipients.append(recipient1)
message.recipients.append(recipient2)
message.body_html_text = html_body
message.body_rtf = rtf_body
message.message_flags.append(MessageFlag.UNSENT)
message.store_support_masks.append(StoreSupportMask.CREATE)
message.save("e:\\output.msg")
**********************************************************************************************************************************
Create message with attachment
**********************************************************************************************************************************
from independentsoft.msg import Message
from independentsoft.msg import Attachment
from independentsoft.msg import Recipient
from independentsoft.msg import ObjectType
from independentsoft.msg import DisplayType
from independentsoft.msg import RecipientType
from independentsoft.msg import MessageFlag
from independentsoft.msg import StoreSupportMask
message = Message()
recipient1 = Recipient()
recipient1.address_type = "SMTP"
recipient1.display_type = DisplayType.MAIL_USER
recipient1.object_type = ObjectType.MAIL_USER
recipient1.display_name = "John Smith"
recipient1.email_address = "John@domain.com"
recipient1.recipient_type = RecipientType.TO
recipient2 = Recipient()
recipient2.address_type = "SMTP"
recipient2.display_type = DisplayType.MAIL_USER
recipient2.object_type = ObjectType.MAIL_USER
recipient2.display_name = "Mary Smith"
recipient2.email_address = "Mary@domain.com"
recipient2.recipient_type = RecipientType.CC
message.subject = "Test"
message.body = "Body text"
message.display_to = "John Smith"
message.display_cc = "Mary Smith"
message.recipients.append(recipient1)
message.recipients.append(recipient2)
message.message_flags.append(MessageFlag.UNSENT)
message.store_support_masks.append(StoreSupportMask.CREATE)
attachment = Attachment(file_path = "e:\\test.pdf")
message.attachments.append(attachment)
message.save("e:\\output.msg")
**********************************************************************************************************************************
Read message and save attachments to file system
**********************************************************************************************************************************
from independentsoft.msg import Message
from independentsoft.msg import Attachment
message = Message(file_path = "e:\\intvalue.msg")
for i in range(len(message.attachments)):
attachment = message.attachments[i]
attachment.save("e:\\" + str(attachment.file_name))
**********************************************************************************************************************************
Create appointment
**********************************************************************************************************************************
import datetime
from independentsoft.msg import Message
appointment = Message()
appointment.message_class = "IPM.Appointment"
appointment.subject = "Test"
appointment.body = "Body text"
appointment.location = "My Office"
appointment.appointment_start_time = datetime.datetime(2019,12,10,8,0,0)
appointment.appointment_end_time = datetime.datetime(2019,12,10,10,0,0)
appointment.save("e:\\appointment.msg")
**********************************************************************************************************************************
Create contact
**********************************************************************************************************************************
import datetime
from independentsoft.msg import Message
contact = Message()
contact.message_class = "IPM.Contact"
contact.subject = "John Smith"
contact.display_name_prefix = "Mr."
contact.display_name = "John Smith"
contact.given_name = "John"
contact.surname = "Smith"
contact.company_name = "Independentsoft"
contact.email1_address = "john@independentsoft.com"
contact.email1_display_as = "John"
contact.email1_display_name = "John"
contact.email1_type = "SMTP"
contact.business_address_city = "NY"
contact.business_address_street = "First Street"
contact.business_address_country = "USA"
contact.business_address = "First Street, NY, USA"
contact.business_phone = "555-666-777"
contact.save("e:\\contact.msg")
**********************************************************************************************************************************
Create task
**********************************************************************************************************************************
import datetime
from independentsoft.msg import Message
from independentsoft.msg import Priority
from independentsoft.msg import TaskStatus
task = Message()
task.message_class = "IPM.Task"
task.subject = "Test"
task.body = "Body text"
task.owner = "John"
task.task_status = TaskStatus.NOT_STARTED
task.priority = Priority.HIGH
task.task_start_date = datetime.datetime(2019,12,20,10,0,0)
task.task_due_date = datetime.datetime(2019,12,22,10,0,0)
task.save("e:\\task.msg")
**********************************************************************************************************************************
Create note
**********************************************************************************************************************************
import datetime
from independentsoft.msg import Message
from independentsoft.msg import NoteColor
note = Message()
note.message_class = "IPM.StickyNote"
note.subject = "Test"
note.body = "Body text"
note.note_color = NoteColor.GREEN
note.note_top = 200
note.note_left = 300
note.note_height = 200
note.note_width = 250
note.save("e:\\note.msg")
Metadata
Release files for independentsoft.msg 1.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| independentsoft.msg-1.6.tar.gz | 86.5 kB | Without provenance | Details for independentsoft.msg-1.6.tar.gz |
Release files / independentsoft.msg-1.6.tar.gz
| Download URL | independentsoft.msg-1.6.tar.gz |
|---|---|
| Size | 86.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bc5bca4a55fc6dbcddc2915e7599bb760612954bfda6f7510c4d0656842c012f
|
|
BLAKE2b-256 checksum How to use checksums |
afb975374e0cf1702cd64086bc3b38f08273b5ddebd3ff55e07c6ed81a1f6db0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.8.0
|
Security for independentsoft.msg 1.6
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.