पर भेजने के बीच अंतर मैं SMTPClient क्लास का उपयोग करके वितरण के लिए किसी SMTP सर्वर पर प्रेषित ई-मेल संदेश बनाने के लिए MailMessage class का उपयोग करने का प्रयास कर रहा हूं। मेरा ईमेल एक्सचेंज सर्वर के माध्यम से Outlook पर कॉन्फ़िगर किया गया है। उपर्युक्त कार्यान्वयन के संबंध में मुझे निम्नलिखित संदेह थे:किसी Exchange सर्वर पर MailMessage भेजने और एक SMTP सर्वर
1) एक्सचेंज सर्वर और एक एसएमटीपी सर्वर के बीच क्या अंतर है?
2) मेरे मामले में, मेरा दृष्टिकोण मेरे प्रमाण पत्र का उपयोग कर एक्सचेंज सर्वर पर कॉन्फ़िगर किया गया है। मुझे एसएमटीपी पता कैसे मिल सकता है ताकि मैं MailMessage क्लास को कार्यान्वित कर सकूं?
3) उपर्युक्त कार्यान्वयन तकनीक संभव नहीं है तो एक्सचेंज सर्वर के आधार पर आवेदन के माध्यम से ईमेल भेजने का कोई विचार?
मैं विज़ुअल स्टूडियो 2008, फ्रेमवर्क 3.5 एसपी 1 का उपयोग कर रहा हूं, सी # के साथ विनफॉर्म एप्लिकेशन पर काम कर रहा हूं। कृपया मुझे अपने संदेहों को दूर करने में मदद करें।
संपादित
मैं निम्नलिखित कोड का उपयोग कर रहा हूँ। यह कोई त्रुटि नहीं फेंकता है, न ही यह काम करता है। मैं भेजने के लिए और अपने आप को ईमेल कोई लाभ नहीं हुआ
public static void CreateMessageWithAttachment(string server)
{
// Specify the file to be attached and sent.
// This example assumes that a file named Data.xls exists in the
// current working directory.
string file = "data.xls";
// Create a message and set up the recipients.
MailMessage message = new MailMessage(
"[email protected]",
"[email protected]",
"Quarterly data report.",
"See the attached spreadsheet.");
// Create the file attachment for this e-mail message.
Attachment data = new Attachment(file, MediaTypeNames.Application.Octet);
// Add time stamp information for the file.
ContentDisposition disposition = data.ContentDisposition;
disposition.CreationDate = System.IO.File.GetCreationTime(file);
disposition.ModificationDate = System.IO.File.GetLastWriteTime(file);
disposition.ReadDate = System.IO.File.GetLastAccessTime(file);
// Add the file attachment to this e-mail message.
message.Attachments.Add(data);
//Send the message.
SmtpClient client = new SmtpClient(server);
// Add credentials if the SMTP server requires them.
client.Credentials = CredentialCache.DefaultNetworkCredentials;
try {
client.Send(message);
}
catch (Exception ex) {
Console.WriteLine("Exception caught in CreateMessageWithAttachment(): {0}",
ex.ToString());
}
data.Dispose();
}
@Phoenix: contoso.com एक उदाहरण डोमेन है।वे ईमेल वास्तविक नहीं हैं। उन्हें मर्ज करने की जरूरत नहीं है। – BoltClock