Dart.Mail Namespace : Textpart Class |
private MailMessage addCustomParts(MailMessage message) { //Add custom header field to message message.Headers.Add("X-Alt-Message", new HeaderField("X-Alt-Message", "Message with Alternatives")); //Create and add alternative parts to a multipart part Textpart part1 = new Textpart("This is alternative 1."); part1.Headers.Add("X-Alt", new HeaderField("X-Alt", "Alternative 1")); Textpart part2 = new Textpart("This is alternative 2."); part2.Headers.Add("X-Alt", new HeaderField("X-Alt", "Alternative 2")); Multipart multipart = new Multipart(Multipart.Alternative); multipart.Parts.Add(part1); multipart.Parts.Add(part2); //Add a MultiPart to the MailMessage message.Parts.Add(multipart); //Add a Resource part to the MailMessage Resource resource = new Resource(new FileStream(Application.StartupPath + "\\myImage.jpg", FileMode.Open), "myImage.jpg"); resource.ContentType = new ContentType("image/jpeg"); resource.ContentId = "<myImage>"; message.Parts.Add(resource); return message; }
Private Function addCustomParts(ByVal message As MailMessage) As MailMessage 'Add custom header field to message message.Headers.Add("X-Alt-Message", New HeaderField("X-Alt-Message", "Message with Alternatives")) 'Create and add alternative parts to a multipart part Dim part1 As New Textpart("This is alternative 1.") part1.Headers.Add("X-Alt", New HeaderField("X-Alt", "Alternative 1")) Dim part2 As New Textpart("This is alternative 2.") part2.Headers.Add("X-Alt", New HeaderField("X-Alt", "Alternative 2")) Dim multipart As New Multipart(Dart.Mail.Multipart.Alternative) multipart.Parts.Add(part1) multipart.Parts.Add(part2) 'Add a MultiPart to the MailMessage message.Parts.Add(multipart) 'Add a Resource part to the MailMessage Dim resource As New Resource(New FileStream(Application.StartupPath & "\myImage.jpg", FileMode.Open), "myImage.jpg") resource.ContentType = New ContentType("image/jpeg") resource.ContentId = "<myImage>" message.Parts.Add(resource) Return message End Function
System.Object
Dart.Mail.Part
Dart.Mail.Resource
Dart.Mail.Textpart
Dart.Mail.Htmlpart