Click here to Skip to main content
15,917,176 members

Comments by Member 3828789 (Top 1 by date)

Member 3828789 22-Aug-13 16:44pm View    
Hi sorry i was out out few a week. So yah i tried your solutions and it didnt send an email. If i just write the above code which i ahve posted it will send an email but with this its even not sending an email. few things i have to clear here might help you. the string logo which i am trying to attache is a full path of a file say "~/images/filename.jpg" so what i did is
add aline on top of yorr code.
String filename = VirtualPathUtility.GetFileName(logo);
and then your code.
Attachment attachment = new Attachment(filename, MediaTypeNames.Application.Octet);
ContentDisposition disposition = attachment.ContentDisposition;
disposition.CreationDate = File.GetCreationTime(filename);
disposition.ModificationDate = File.GetLastWriteTime(filename);
disposition.ReadDate = File.GetLastAccessTime(filename);
disposition.FileName = Path.GetFileName(filename);
disposition.Size = new FileInfo(filename).Length;
disposition.DispositionType = DispositionTypeNames.Attachment;
mail.Attachments.Add(attachment);

let me know if you found any problem.
Thanks.