asp.net mvc - Image showing in attachment instead of mail body -


i have problem embedded image in email. when receiving mail show image in attachment instead of message body , have add image dynamically in message body. , have set "cid" have not success. have set ishtmlbody = true not showing image in body. please solve problem.

my code here:

this body message:

 const string = "test@gmail.com";         msg.to.add(to);         msg.from = new mailaddress("test@gmail.com");         msg.subject = "test";         int count = 1;         int stratindex = 0;         //create altenative view         alternateview alternative = alternateview.createalternateviewfromstring(strmailcontent, null, mediatypenames.text.html);         while ((lastindex = strmailcontent.indexof(findstr, stratindex, stringcomparison.ordinal)) != -1)         {             int srcstartindex =convert.toint32(strmailcontent.indexof("src", lastindex, stringcomparison.ordinal)) + 5;             int srcendindex = strmailcontent.indexof(@"'", srcstartindex, stringcomparison.ordinal);             string imgsrc = strmailcontent.substring(srcstartindex, srcendindex - srcstartindex);             string path = imgsrc;             // atteched resource             // set cid              var resource = new linkedresource(path, "image/jpg");             string cid = "companylogo" + count;             //now add alternateview              resource.contentid = cid;             alternative.linkedresources.add(resource);             msg.alternateviews.add(alternative);             //now append body of mail               strmailcontent = strmailcontent.replace(strmailcontent.substring(srcstartindex, srcendindex - srcstartindex), "cid:" + cid);             stratindex = strmailcontent.indexof("<br/>", lastindex, stringcomparison.ordinal) + 5;             strmailcontent = strmailcontent.remove(stratindex - 5, 5);              stratindex = stratindex - 5;             count++;         } 

show in screen short red area show attachment , yellow area show blank body.

how solve problem.


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -