Author |
|
juris Groupie
Joined: 27 June 2011 Location: Italy
Online Status: Offline Posts: 72
|
Posted: 08 April 2013 at 11:37pm | IP Logged
|
|
|
Hi,
How do I remove Content-ID delimiters "< and >"?
Thanks in advance
Lello
|
Back to Top |
|
|
Igor AfterLogic Support
Joined: 24 June 2008 Location: United States
Online Status: Offline Posts: 6104
|
Posted: 08 April 2013 at 11:59pm | IP Logged
|
|
|
There are no special functions for that, you could do that in your code by simply taking a substring from string which is surrounded by those characters.
But actually, it's not fully clear to us why would you need to delete those characters. I believe Attachment.ContentID does not include those, even though they're found in attachment's headers within MIME source of message.
--
Regards,
Igor, AfterLogic Support
|
Back to Top |
|
|
juris Groupie
Joined: 27 June 2011 Location: Italy
Online Status: Offline Posts: 72
|
Posted: 09 April 2013 at 3:01am | IP Logged
|
|
|
Hi Igor,
Code:
msg.Attachments.Add("IndiceBusta.xml", "MyTarget.xml",
"MY-ContentID", "text/xml", coll, NewAttachmentOptions.None, MailTransferEncoding.Raw7bit );
MIME:
------=_NextPart_000_6BE7_CB5CAE79.A52FBCF6
Content-Type: text/xml;
name="MyTarget.xml"
Content-Disposition: attachment;
filename="MyTarget.xml"
Content-Transfer-Encoding: 7bit
Content-ID: <MY-ContentID>
MIME automatically adds "<" and ">"
How I can write Content-ID: without "<" and ">"
There is an option?
Regards,
Lello
|
Back to Top |
|
|
Igor AfterLogic Support
Joined: 24 June 2008 Location: United States
Online Status: Offline Posts: 6104
|
Posted: 09 April 2013 at 3:10am | IP Logged
|
|
|
Content-ID always contains those characters, one won't find Content-ID without those anywhere in RFC specification.
--
Regards,
Igor, AfterLogic Support
|
Back to Top |
|
|
juris Groupie
Joined: 27 June 2011 Location: Italy
Online Status: Offline Posts: 72
|
Posted: 09 April 2013 at 9:36am | IP Logged
|
|
|
Hi Igor,
I use MIME to encrypt an envelope.
The delimiters "<" and ">" give a lot of problems in the XML.
You can create an option to remove the delimiters in the MIME file?
Regards, Lello
------=_NextPart_000_5C3E_02B7F241.89134C10
Content-Type: text/xml;
name="IndiceBusta.xml"
Content-ID: IndiceBusta.xml
Content-Disposition: attachment;
filename="IndiceBusta.xml"
Content-Transfer-Encoding: 7bit
<?xml version="1.0"?><!DOCTYPE IndiceBusta SYSTEM "IndiceBusta.dtd"><IndiceBusta><Atto Nome="Ricorso per decreto ingiuntivo.pdf.p7m" ID="A3" /><Allegato Nome="DatiAtto.xml" Tipo="DA" ID="A2" /><Allegato Nome="NotaIscrizioneRuolo.pdf.p7m" Tipo="IR" ID="A4" /></IndiceBusta>
------=_NextPart_000_5C3E_02B7F241.89134C10
Content-Type: text/xml;
name="DatiAtto.xml"
Content-ID: <A2>
Content-Disposition: inline;
filename="DatiAtto.xml"
Content-Transfer-Encoding: base64
|
Back to Top |
|
|
juris Groupie
Joined: 27 June 2011 Location: Italy
Online Status: Offline Posts: 72
|
Posted: 09 April 2013 at 8:52pm | IP Logged
|
|
|
Hi Igor,
I found how to do ...
foreach (Header hdr in msg.Attachments[MyIndex].Headers )
{
if (hdr.Name == "Content-ID")
{
hdr.Value = hdr.Value.Replace("<", "").Replace(">", "");
}
}
Regards, Lello
|
Back to Top |
|
|
juris Groupie
Joined: 27 June 2011 Location: Italy
Online Status: Offline Posts: 72
|
Posted: 09 April 2013 at 9:02pm | IP Logged
|
|
|
// For every attachment...
foreach (MailBee.Mime.Attachment attach in msg.Attachments)
{
foreach (Header hdr in attach.Headers)
{
if (hdr.Name == "Content-ID")
{
hdr.Value = hdr.Value.Replace("<", "").Replace(">", "");
}
}
}
|
Back to Top |
|
|
Alex AfterLogic Support
Joined: 19 November 2003
Online Status: Offline Posts: 2206
|
Posted: 09 April 2013 at 11:27pm | IP Logged
|
|
|
Your approach is wrong. To make a document be XML compliant, you must encode special characters, not to remove them. It's a common rule, not only for XML or MIME. And what if "<" and ">" appear in other parts of the message? Let's say, in Subject field or in the text body? You'll ruin the text written by the message author who intentionally wrote something like "if a > b then c" in the text?
For instance, you can't use "<" and ">" in HTML as-is but you encode it with < and > and thus avoid loss of data. I guess something similar exists in XML but this subject is not actually connected with MailBee. If you need help on general programming subjects, you can ask on various common programming forums for that.
Regards,
Alex
|
Back to Top |
|
|
juris Groupie
Joined: 27 June 2011 Location: Italy
Online Status: Offline Posts: 72
|
Posted: 09 April 2013 at 11:48pm | IP Logged
|
|
|
Hi Alex,
I send the encrypted message to a SOAP server that does not recognize correctly the "&-lt;" and "&-gt;" in XML. The only solution is to remove angle brackets surrounding Content-ID
http://weblogs.sqlteam.com/mladenp/archive/2008/10/21/Different-ways-how-to-escape-an-XML-string-in-C.aspx
Regards, Lello
|
Back to Top |
|
|
juris Groupie
Joined: 27 June 2011 Location: Italy
Online Status: Offline Posts: 72
|
Posted: 09 April 2013 at 11:59pm | IP Logged
|
|
|
Alex wrote:
Your approach is wrong. To make a document be XML compliant, you must encode special characters, not to remove them. It's a common rule, not only for XML or MIME. And what if "<" and ">" appear in other parts of the message? Let's say, in Subject field or in the text body? You'll ruin the text written by the message author who intentionally wrote something like "if a > b then c" in the text? |
|
|
Dear Alex,
You read my code?
I just take off the delimiters around Content-ID
I do not edit the rest of the message
Regards, Lello
|
Back to Top |
|
|
juris Groupie
Joined: 27 June 2011 Location: Italy
Online Status: Offline Posts: 72
|
Posted: 10 April 2013 at 12:32am | IP Logged
|
|
|
I send the encrypted message to a SOAP server that does not recognize correctly the "&-lt;" and "&-gt;" characters in XML MIME part. The only solution is to remove angle brackets surrounding Content-ID
|
Back to Top |
|
|
Alex AfterLogic Support
Joined: 19 November 2003
Online Status: Offline Posts: 2206
|
Posted: 10 April 2013 at 12:44am | IP Logged
|
|
|
< and > is a valid replacement for <> in XML. If this does not work with your SOAP server, you should address this issue to the server's vendor. Of course, you can alter the message the way you do as a workaround.
Regards,
Alex
|
Back to Top |
|
|
juris Groupie
Joined: 27 June 2011 Location: Italy
Online Status: Offline Posts: 72
|
Posted: 10 April 2013 at 9:08am | IP Logged
|
|
|
The correct format of the content id is enclosed in angle brackets as per RFC.
But the Web URI is without the angle brackets.
See: http://stackoverflow.com/questions/8004860/content-id-format
|
Back to Top |
|
|
Alex AfterLogic Support
Joined: 19 November 2003
Online Status: Offline Posts: 2206
|
Posted: 10 April 2013 at 11:44pm | IP Logged
|
|
|
OK, it's your app and it's up to you how to write it.
Regards,
Alex
|
Back to Top |
|
|
juris Groupie
Joined: 27 June 2011 Location: Italy
Online Status: Offline Posts: 72
|
Posted: 11 April 2013 at 11:42pm | IP Logged
|
|
|
Dear Alex,
I believe that You should create an MailBee option that takes away these delimiters. This is just a suggestion!
Regards, Lello
|
Back to Top |
|
|
Igor AfterLogic Support
Joined: 24 June 2008 Location: United States
Online Status: Offline Posts: 6104
|
Posted: 11 April 2013 at 11:52pm | IP Logged
|
|
|
If you believe many other people might need this feature, you can add a vote at afterlogic.uservoice.com. When the feature gets a substantial number of votes, that increases a chance the feature is implemented in subsequent releases.
--
Regards,
Igor, AfterLogic Support
|
Back to Top |
|
|