muquit / mailsend

A program to send mail via SMTP from command line
Other
297 stars 68 forks source link

Feedback - using "content-id", "inline" and "attachment" dispositions for outlook #122

Open pgmrgeek opened 6 years ago

pgmrgeek commented 6 years ago

Howdy,

Thought this was important enough to pass along. I send .jpegs in my email using both "inline" and "attachment" dispositions, mime-type "image/jpeg". Five .jpegs are used for cosmetics in the html email for banners, icons, etc. These 5 also have a CID declared for use in the email body. The 6th .jpeg attachment is what I am wanting the user to receive and save. If I declare a CID for this 6th image, then outlook forces it into "inline" and bugs within outlook 2010 and prior, don't allow it to be copied and saved. So, by not giving it a CID and using the disposition "attachment", outlook keeps it as an attachment that can be saved, but I can't use it in the email body. Its a tradeoff..

Here's the code in VB -

cmdln = " -smtp " & Globals.tmpServerURL & " -domain " & Globals.tmpServerURL & " -port " & Globals.tmpServerPort & " -pass " & Globals.tmpPassword & " -f " & Globals.tmpAcctEmailAddr & " -t " & recip & " -sub """ & Globals.EmailToCaption(Globals.EmailFifoOut) & """" & " -auth-plain -v -log c:\onsite\software\email.log " & _ " -sub " & """" & Globals.EmailToCaption(Globals.EmailFifoOut) & """" cmdln = cmdln & " -disposition ""inline"" -mime-type ""image/jpeg"" " cmdln = cmdln & " -content-id ""img_01"" -attach c:\onsite\software\email_img01.jpg " cmdln = cmdln & " -content-id ""img_02"" -attach c:\onsite\software\email_img02.jpg " cmdln = cmdln & " -content-id ""img_03"" -attach c:\onsite\software\email_img03.jpg " cmdln = cmdln & " -content-id ""img_04"" -attach c:\onsite\software\email_img04.jpg " cmdln = cmdln & " -content-id ""img_05"" -attach c:\onsite\software\email_img05.jpg " cmdln = cmdln & " -disposition ""attachment"" -mime-type ""image/jpeg"" " cmdln = cmdln & " -content-id ""eventpic"" -attach """ & fname & """ -v -log " & "c:\onsite\software\email.log" cmdln = cmdln & " -attach """ & fname & """ -v -log " & "c:\onsite\software\email.log" cmdln = cmdln & " -attach c:\onsite\software\emailbody.html,text/html,i"

..Doug

pgmrgeek commented 6 years ago

Round two. Had to rewrite the code because attachments were being renamed as "untitled" and lost their file extension. I think the problem has to do from switching the disposition from inline to attachment. I was attaching the content first as inline, then the final image as attachment, so I juggled switches around and things worked. Dunno why.. Here's the list of switches I'm using now -

mailsend -smtp ??? -domain ??? -port ?? -user ??? -pass ??? -f ??? -t ??? -auth-plain -v -log ??? -sub "???" -attach c:\onsite\printed\00043_p1_m2_bk1_n001_f01_de.jpg,image/jpg,a -attach c:\onsite\software\emailbody.html,text/html,i -content-id "img_01" -attach c:\onsite\software\email_img01.jpg,image/jpg,i -content-id "img_02" -attach c:\onsite\software\email_img02.jpg,image/jpg,i -content-id "img_03" -attach c:\onsite\software\email_img03.jpg,image/jpg,i -content-id "img_04" -attach c:\onsite\software\email_img04.jpg,image/jpg,i -content-id "img_05" -attach c:\onsite\software\email_img05.jpg,image/jpg,i