Quickstart
Quickstart: एक MSG फ़ाइल बनाना और पढ़ना
यह गाइड आपको एक ताजा स्थापना से कुछ चरणों में काम करने वाले एमएसजी फ़ाइल तक ले जाता है। MapiMessage से aspose.email_foss.
Prerequisites
| Requirement | Detail |
|---|---|
| Python | 3.10 or later |
| पीपी | वर्तमान संस्करण |
| OS | Windows, MacOS या Linux के बारे में जानकारी |
| Dependencies | कोई नहीं - शुद्ध Python |
चरण 1 - पैकेज स्थापित करें
pip install aspose-email-fossस्थापना की पुष्टि करें:
from aspose.email_foss.msg import MapiMessage
print("aspose-email-foss is ready.")चरण 2 – एक MSG फ़ाइल बनाएं
उपयोग करें MapiMessage.create() एक संदेश बनाने के लिए, भेजने की संपत्ति सेट करें PropertyId, एक रिसीवर जोड़ें, फ़ाइल जोड़ाएं और कॉल करें save() लिखने के लिए .msg उत्पादन के लिए।.
from datetime import datetime, timezone
from aspose.email_foss import msg
message = msg.MapiMessage.create("Hello from Python", "This is the message body.")
message.set_property(msg.PropertyId.SENDER_NAME, "Build Agent")
message.set_property(msg.PropertyId.SENDER_EMAIL_ADDRESS, "agent@example.com")
message.set_property(
msg.PropertyId.MESSAGE_DELIVERY_TIME,
datetime(2026, 1, 1, 9, 0, tzinfo=timezone.utc),
)
message.add_recipient("alice@example.com", display_name="Alice Example")
message.add_attachment("readme.txt", b"Hello, world!\n", mime_type="text/plain")
message.save("quickstart.msg")
print("quickstart.msg written.")चरण 3 – MSG फ़ाइल को वापस पढ़ें
फ़ाइल को बचाने के लिए MapiMessage.from_file() और पहुंच के लिए subject और body संपत्ति के लिए सीधे।.
from aspose.email_foss import msg
with msg.MapiMessage.from_file("quickstart.msg") as message:
print(f"Subject : {message.subject}")
print(f"Body : {message.body}")चरण 4 – EML में परिवर्तित करें
to_email_message() एक मानक Python वापस लाता है email.message.EmailMessage उपयोग करें - उपयोग to_email_bytes() एक तैयार भेजने के लिए लिखने RFC 5322 .eml फ़ाइल है।.
from pathlib import Path
from aspose.email_foss import msg
with msg.MapiMessage.from_file("quickstart.msg") as message:
Path("quickstart.eml").write_bytes(message.to_email_bytes())
print("quickstart.eml written.")अगले कदम
- स्थापना गाइड: वर्चुअल-पर्यावरण सेटअप, पाइप विकल्प और सत्यापन
- एक समीक्षा शुरू करने के लिए: आवश्यकताओं का सारांश और क्षमता समीक्षा
- विशेषताएं और कार्यक्षमताएँ: हर फ़ंक्शन में गहराई से डाइव
- API रेफ़रेंस