Я пытаюсь отправить электронное письмо с использованием amazon WS SMTP, отправляет с успехом, но я никогда не получаю письмо. Когда я отправляю его без вложения, я получаю его с успехом.Отправка электронной почты с прикрепленными файлами с использованием Amazon AWS SMTP
Вот мой код
// Create an SMTP client with the specified host name and port.
using (SmtpClient client = new SmtpClient(ssHost, ssPort))
{
// Create a network credential with your SMTP user name and password.
client.Credentials = new System.Net.NetworkCredential(ssSMTP_Username, ssSMTP_Password);
// Use SSL when accessing Amazon SES. The SMTP session will begin on an unencrypted connection, and then
// the client will issue a STARTTLS command to upgrade to an encrypted connection using SSL.
client.EnableSsl = true;
// Send the email.
MailMessage message = new MailMessage();
try
{
//creates a messages with the all data
message.From = new MailAddress(ssFrom, ssFromName);
//message.To.Add(ssTo);
//To
List<String> toAddresses = ssTo.Split(',').ToList();
foreach (String toAddress in toAddresses)
{
message.To.Add(new MailAddress(toAddress));
}
//cc
List<String> ccAddresses = ssCC.Split(',').Where(y => y != "").ToList();
foreach (String ccAddress in ccAddresses)
{
message.CC.Add(new MailAddress(ccAddress));
}
//bcc
List<String> BccAddresses = ssBcc.Split(',').Where(y => y != "").ToList();
foreach (String ccAddress in ccAddresses)
{
message.Bcc.Add(new MailAddress(ccAddress));
}
//replyTo
if (ssReplyTo != null)
{
message.ReplyToList.Add(new MailAddress(ssReplyTo));
}
//email
message.Subject = ssSubject;
message.Body = ssBody;
message.IsBodyHtml = true;
//Attachment
foreach (RCAttachmentRecord attchmentRec in ssAttachmenstList){
System.IO.MemoryStream ms = new System.IO.MemoryStream(attchmentRec.ssSTAttachment.ssBinary);
Attachment attach = new Attachment(ms, attchmentRec.ssSTAttachment.ssFilename);
message.Attachments.Add(attach);
ssErrorMessage = ssErrorMessage + "||" + attchmentRec.ssSTAttachment.ssFilename+"lenght:"+attchmentRec.ssSTAttachment.ssBinary.Length;
}
client.Send(message);
}
Источник: http://docs.aws.amazon.com/ses/latest/DeveloperGuide/send-using-smtp-net.html
Можете ли вы разместить больше кода? Чтобы помочь вам, нам нужно знать, как вы определяете и заполняете 'ssAttachmenstList' - спасибо. – Taterhead
Проверьте этот вопрос, возможно, сможет вам помочь? http://stackoverflow.com/questions/2825950/sending-email-with-attachments-from-c-attachments-arrive-as-part-1-2-in-thunde –
@Taterhead изображение этой переменной как ArrayList – Luis