PDA

View Full Version : ارسال ایمیل همراه با فایل اتچ شده



نیما حتمی
شنبه 25 دی 1389, 15:08 عصر
با سلام به همه دوستان گلم

بچه ها من دنبال برنامه ارسال ایمیلی که فایل اتچ شده هم داره می گردم.هرچی گشتم نتونستم اینجا پیدا کنم اگه کسی بلده کدشو یا یه منبعی رو معرفی کنه

ممنونم

ایمان مدائنی
شنبه 25 دی 1389, 15:21 عصر
در همين سايت وجود دارد
ايملت را در پيام خصوصي بده برات ميل كنم

Hadirj
شنبه 25 دی 1389, 15:22 عصر
این یه متد واسه اینکار



public static string SendMessageWithAttachment(string sendTo, string
sendFrom, string sendSubject, string sendMessage, ArrayList
attachments)
{
try
{
// validate email address
bool bTest = ValidateEmailAddress(sendTo);

if (bTest == false)
return "Invalid recipient email address: " + sendTo;

// Create the basic message
MailMessage message = new MailMessage(
sendFrom,
sendTo,
sendSubject,
sendMessage);

// The attachments array should point to a file location
// where
// the attachment resides - add the attachments to the
// message
foreach (string attach in attachments)
{
Attachment attached = new Attachment(attach,
MediaTypeNames.Application.Octet);
message.Attachments.Add(attached);
}

// create smtp client at mail server location
SmtpClient client = new
SmtpClient(Properties.Settings.Default.SMTPAddress );

// Add credentials
client.UseDefaultCredentials = true;

// send message
client.Send(message);

return "Message sent to " + sendTo + " at " +
DateTime.Now.ToString() + ".";
}
catch (Exception ex)
{
return ex.Message.ToString();
}
}



منبع (http://www.c-sharpcorner.com/uploadfile/scottlysle/emailattachmentscs08052008234321pm/emailattachmentscs.aspx)

نیما حتمی
شنبه 25 دی 1389, 16:24 عصر
کسی نیست نمونه برنامه بزاره برام؟

Hadirj
شنبه 25 دی 1389, 17:07 عصر
کسی نیست نمونه برنامه بزاره برام؟

پس اینی که گذاشتم چیه؟

نیما حتمی
یک شنبه 26 دی 1389, 09:45 صبح
هادی جان خیلی ممنونم

نیما حتمی
یک شنبه 26 دی 1389, 12:22 عصر
هادی جان اون منبع ای که گذاشتی برام اررور می ده و درست کار نمی کنه

میشه اگه نمونه ای دیگه دارین بدین؟