I took the code from the article, still the same problem.. in Outlook I get a nice embedded pic,
In Gmail- the pic is attached.
It seems there is a specific problem with Gmail displaying embedded images.
Did you manage to get a mail with embedded image to display correctly in Gmail?
I also tried the base64 method, and that also worked correctly only when the mail was opened in Outlook.
Method 1:
Set tmpEmail=##class(%Net.SMTP).%New() Set tmpEmail.smtpserver="xyz" Set msg=##class(%Net.MailMessage).%New() Set msg.From="from.." Set msg.Charset="Windows-1255" D msg.To.Insert("to..") Set msg.Subject="testing" set msg.IsHTML=1 set msg.MultiPartType="related" do msg.AttachFile("c:\xyzxyz\","a.png") set part=msg.Parts.GetAt(1) set part.ContentType="image/png" set part.InlineAttachment=1 // otherwise, the default is attachment. graphic inside html do part.Headers.SetAt("id1","Content-ID") do msg.TextData.Write("<b>Hello< / b>, </b><font color='red'>World<font color='red'></font>!") do msg.TextData.Write("<br/><img src='cid:id1'>") s status= tmpEmail.Send(msg)
Method 2 base64
Set tmpEmail=##class(%Net.SMTP).%New() Set tmpEmail.smtpserver="xyz" Set msg=##class(%Net.MailMessage).%New() Set msg.From="from.." Set msg.Charset="Windows-1255" D msg.To.Insert("to..") Set msg.Subject="testing base64" set msg.IsHTML=1 set msg.MultiPartType="related" set stream=##class(%GlobalBinaryStream).%New() do stream.Write($system.Encryption.Base64Decode("iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAACXBIWXMAAAsTAAALEwEAmpwYAAADUUlEQVR42lWTWUwTURSGaUtIKY5QweISTUzceDGu0Rj1xURjTNQEE+ODGn0hPhBEQdqZztahBbrAtFih1Fprh9IBiVLLErZSU7BUoS7VqNH44ovx0S0ovdfO4Ez04cw9Ofec7/5zzr15NEnkUxSVFx8ObZ1x7nzHN6z9nOhnzOFwWCnECcKoEFbBRrrp6iF/XRvD0BoplkdTuAiIhtt3P3Fu+jJlKlkM1WoXLFjVeSnpXrC94gV3ciJp1X0L1K7+NtDfvXdpj1TmmUwm8QTfLa867T+ceWTSwO5r5b87XNaDEoBrv3p2Ai+AU1Qh5OiDGS4UXi4roAisQHBiYfJS2obAVPMyELYcGxViOIaKcLaNLXzadej5nBUBPXW6hdYW0z4RQOYUXK2tUfr8QeXL0Kn4JKEBk7QWdtrrLggJJEmoCBxVCf50qIaaa0HABFkEPZaLNnGfwPNFGV0u05Y554bvMQoBPLbxs9t9QydJpHP/KayRbsf+pG1NdgTTgDuGXa8dbS41ZtArxaQYT1WlHVqYaloGOcvJIan4X2MdViTl3vExbS+GPfXlvzzutj1LPch9HrYea59t0YIRtAAO+PQuIWYwNKikYty41Iuk/3TvMzsCB9HcQR7msgzgjZs7Z5rLQPR6PojeJW2d3oDCoG/IlwAYqlexbp/i9eB19ziuBoMoAlrR03YZ0G8+0JFhS8EjuhD6zWfuCTEjppcBOKYX1bwaqA5MM2oYZ4pBy7XjrAyY7sPqU01FcNZW/jtwZeXXVpt5u1RM4JhYzHFBddqz5/28fUU2NwngtVUbZUCE79o6x67/MYiXLiSbS8D9xp1vI7znkLvDK07A5/MiT7mzdxMMAsdMqxaiWDHkgzePigBUXy9KTfdWeVKNSjjPrvv5uKkYxszlIHX7eDLeVfkgbt30bt5eAlOOtT9nLRrI03szrOumOtcb4SrTSj2KKfr4nuUZ7kR8HFPAYXLlYqxRl43TGjjTWAhHCC1MNK/+lWA0cJLRgfsh95G/N1H136z7+BCSuHMuMEGVLo4a1XCKKcuO0WXZBw1FcNighmPWbe8jIeeJpdFiCrkHguWUyM92NBKseBut8T92bfsw66z49IyrHH2T5CvlqeCYUvL/ANIZ7+ohXSdWAAAAAElFTkSuQmCC")) do msg.AttachStream(stream,"id1")
set part=msg.Parts.GetAt(1) set part.ContentType="image/png" set part.InlineAttachment=1 // otherwise, the default is attachment. graphic inside html do part.Headers.SetAt("id1","Content-ID")
do msg.TextData.Write("<b>Hello< / b>, </b><font color='red'>World<font color='red'></font>!") do msg.TextData.Write("<br/><img src='cid:id1'>") s status= tmpEmail.Send(msg)
go to post
I got it to work,
Turns out that angle brackets must be added in the Content-ID header for this to work in Gmail.
It's mentioned in this article , remark by masoudmanson.
https://stackoverflow.com/questions/41946783/gmail-blocking-small-embedd...
Thanks for helping me solve this problem! I appreciate it very much.
go to post
Hi,
I took the code from the article, still the same problem.. in Outlook I get a nice embedded pic,
In Gmail- the pic is attached.
It seems there is a specific problem with Gmail displaying embedded images.
Did you manage to get a mail with embedded image to display correctly in Gmail?
I also tried the base64 method, and that also worked correctly only when the mail was opened in Outlook.
Method 1:
Set tmpEmail=##class(%Net.SMTP).%New()
Set tmpEmail.smtpserver="xyz"
Set msg=##class(%Net.MailMessage).%New()
Set msg.From="from.."
Set msg.Charset="Windows-1255"
D msg.To.Insert("to..")
Set msg.Subject="testing"
set msg.IsHTML=1
set msg.MultiPartType="related"
do msg.AttachFile("c:\xyzxyz\","a.png")
set part=msg.Parts.GetAt(1)
set part.ContentType="image/png"
set part.InlineAttachment=1 // otherwise, the default is attachment. graphic inside html
do part.Headers.SetAt("id1","Content-ID")
do msg.TextData.Write("<b>Hello< / b>, </b><font color='red'>World<font color='red'></font>!")
do msg.TextData.Write("<br/><img src='cid:id1'>")
s status= tmpEmail.Send(msg)
Method 2 base64
Set tmpEmail=##class(%Net.SMTP).%New()
Set tmpEmail.smtpserver="xyz"
Set msg=##class(%Net.MailMessage).%New()
Set msg.From="from.."
Set msg.Charset="Windows-1255"
D msg.To.Insert("to..")
Set msg.Subject="testing base64"
set msg.IsHTML=1
set msg.MultiPartType="related"
set stream=##class(%GlobalBinaryStream).%New()
do stream.Write($system.Encryption.Base64Decode("iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAACXBIWXMAAAsTAAALEwEAmpwYAAADUUlEQVR42lWTWUwTURSGaUtIKY5QweISTUzceDGu0Rj1xURjTNQEE+ODGn0hPhBEQdqZztahBbrAtFih1Fprh9IBiVLLErZSU7BUoS7VqNH44ovx0S0ovdfO4Ez04cw9Ofec7/5zzr15NEnkUxSVFx8ObZ1x7nzHN6z9nOhnzOFwWCnECcKoEFbBRrrp6iF/XRvD0BoplkdTuAiIhtt3P3Fu+jJlKlkM1WoXLFjVeSnpXrC94gV3ciJp1X0L1K7+NtDfvXdpj1TmmUwm8QTfLa867T+ceWTSwO5r5b87XNaDEoBrv3p2Ai+AU1Qh5OiDGS4UXi4roAisQHBiYfJS2obAVPMyELYcGxViOIaKcLaNLXzadej5nBUBPXW6hdYW0z4RQOYUXK2tUfr8QeXL0Kn4JKEBk7QWdtrrLggJJEmoCBxVCf50qIaaa0HABFkEPZaLNnGfwPNFGV0u05Y554bvMQoBPLbxs9t9QydJpHP/KayRbsf+pG1NdgTTgDuGXa8dbS41ZtArxaQYT1WlHVqYaloGOcvJIan4X2MdViTl3vExbS+GPfXlvzzutj1LPch9HrYea59t0YIRtAAO+PQuIWYwNKikYty41Iuk/3TvMzsCB9HcQR7msgzgjZs7Z5rLQPR6PojeJW2d3oDCoG/IlwAYqlexbp/i9eB19ziuBoMoAlrR03YZ0G8+0JFhS8EjuhD6zWfuCTEjppcBOKYX1bwaqA5MM2oYZ4pBy7XjrAyY7sPqU01FcNZW/jtwZeXXVpt5u1RM4JhYzHFBddqz5/28fUU2NwngtVUbZUCE79o6x67/MYiXLiSbS8D9xp1vI7znkLvDK07A5/MiT7mzdxMMAsdMqxaiWDHkgzePigBUXy9KTfdWeVKNSjjPrvv5uKkYxszlIHX7eDLeVfkgbt30bt5eAlOOtT9nLRrI03szrOumOtcb4SrTSj2KKfr4nuUZ7kR8HFPAYXLlYqxRl43TGjjTWAhHCC1MNK/+lWA0cJLRgfsh95G/N1H136z7+BCSuHMuMEGVLo4a1XCKKcuO0WXZBw1FcNighmPWbe8jIeeJpdFiCrkHguWUyM92NBKseBut8T92bfsw66z49IyrHH2T5CvlqeCYUvL/ANIZ7+ohXSdWAAAAAElFTkSuQmCC"))
do msg.AttachStream(stream,"id1")
set part=msg.Parts.GetAt(1)
set part.ContentType="image/png"
set part.InlineAttachment=1 // otherwise, the default is attachment. graphic inside html
do part.Headers.SetAt("id1","Content-ID")
do msg.TextData.Write("<b>Hello< / b>, </b><font color='red'>World<font color='red'></font>!")
do msg.TextData.Write("<br/><img src='cid:id1'>")
s status= tmpEmail.Send(msg)
go to post
Thank you!
I will look into it.
go to post
Hi,
Thank you, the link does not open for me.
Can you post the code example?
go to post
Thank you very much Peter!
I will look into it now.
I really appreciate your effort to help!
Regards,
Nael Naseraldeen
go to post
Hi,
Ok. here is the code, it's a minimal code of a many to many relationship:
Class TafnitTest.Student Extends (%Persistent, %JSON.Adaptor, %Populate)
{
Property MyName As %String;
Relationship Teachers As TafnitTest.TechersToStudents [ Cardinality = many, Inverse = Student ];
}
{
Property MyName As %String;
}
{
Relationship Student As TafnitTest.Student [ Cardinality = one, Inverse = Teachers ];
Index StudentIndex On Student;
Relationship Tracher As TafnitTest.Teacher [ Cardinality = one, Inverse = Students ];
Index TracherIndex On Tracher;
}
Also I will attach the code as an XML export for convenience of importing and testing, If I find a way to do upload a file here..
after creating the classes, populate:
W ##CLASS(TafnitTest.Teacher).Populate(100)
W ##CLASS(TafnitTest.Student).Populate(100)
W ##CLASS(TafnitTest.TeachersToStudents).Populate(100)
And the JSON Export:
d ##CLASS(TafnitTest.Student).%OpenId(1).%JSONExport()
{"MyName":"O3183","Teachers":[{},{}]}
The JSON indicated that two teachers teach this student, but not the details.
In my post, the id is a property I added to the intermediate class. I did not add it in this minimal example.
Thanks!
Nael Naseraldeen
go to post
Thanks,
I have another server, that is not in the network with the proxy I mentioned, and it does work with default settings as you said.
The problem is only when I must go through the proxy.
It's possible that the HttpRequest class is unable to handle this situation, but I am hoping that this is not the case.
go to post
Yes of course
go to post
I understand.
Thanks, all comments have been helpful!
Regards,
Nael
go to post
Hi,
What I mean by a simple string, is a value that you can send Via a web service for example.
Thanks.
go to post
Nice!
I did not know this was possible.
Thank you!
go to post
Thank you Alexander,
I was not familiar with $stack , might be useful in various situations.
go to post
Hi,
Thank you,
That would work if the caller is nice enough to set the second variable to null before calling the function.
But he may not do it..
So if the function is:
if $d(Param2) {
S Answer= " 2 params"
} Else {
S Answer= " 1 params"
}
S Param2="it's all good"
Q Answer
USER>w $$MyFunc^%ZWBNAEL(1)
1 params
USER>w $$MyFunc^%ZWBNAEL(1,.V)
1 params
go to post
thank you Samuel for elaborating with more useful information.
go to post
thank you very much Parvin!
Regards,
Nael
go to post
Thank you Gertjan!
when I write anything to EntityBody of the request, I don't get the length required error anymore.
I guess it makes sense, when using PUT, there is no point in sending an empty EntityBody.
Regards,
Nael
go to post
Thanks Alexander!
that's a very useful tip, I should have read the whole $ZCONVERT documentation..
still, I think the most elegant solution to this specific problem is the suggestion by Dmitry-
not using ZCVT at all, but using the TranslateTable Property of %Stream.FileCharacter
Regards,
Nael
go to post
Thank you Robert,
We are aware of this parameter and we change it in some of our servers,
But right now we need to write code that works even without it being enabled.
Regards,
Nael
go to post
Thanks Dmitry!
That does solve the problem.
Regards,
Nael
go to post
Hi,
This is a very usefull article, thank you!
But it seems strange that Cache does not support exporting classes to JSON in a native way.
We can use %ZEN.Auxiliary.altJSONProvider , but for some reason, %Date properties are not handled
correctly - they are not converted to ODBC format. at least in Cache 2016.2
is this issue fixed in later Cache Versions?
Thanks,
Nael