0 votes

Hi,
i want to change the content-type to "Application/EDIFACT" how can we manange this?

i use this:

contentType = "Application/EDIFACT"

MimeData mime = _message.AddAttachment(aBytes);

if (!string.IsNullOrEmpty(contentType))
{
        mime.ContentTypeHeader.Name =  contentType;
}

but result gives:

Content-Type: multipart/mixed;
boundary="----=NextPart30015890.623498993961"
MIME-Version: 1.0
Date: Thu, 29 Jun 2017 08:50:19 +0200
Message-ID: 234eb8a8-568a-41a3-bd3a-1c8e338d5bd8@mail.dll
Subject: Test mailt
To: "" me@somewhere.com
Priority: urgent

------=NextPart30015890.623498993961
Content-Type: text/plain;
charset="utf-8"
Content-Transfer-Encoding: 7bit

------=NextPart30015890.623498993961
Content-Type: application/octet-stream;
name="Application/EDIFACT"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment

UNB+UNOA:2+V.O.F. Blablabla:ZZ+:ZZ+170627:0510+062718588=
340++ALF'
UNH+062718588340+CLOCKT:003:006:EF'
BGM+493'
DTM+97:20170627:102'
NAD+BY+999999'
NAD+FLA+74'
NAD+SE+8713783418383:160:9'
LIN+++110252:VBN'
DTM+9:051008:402'
NAD+MF+283234'
RFF+AGJ:2164'
RFF+FAC:1'
RFF+FAN:636941'
RFF+BT:07401178021640000001'
RFF+VN:0741780102164'
QTY+52:25'
QTY+66:1'
PRI+INV:0.480'
IMD++S20+075'
IMD++S21+030'
IMD++S62+EC'
IMD++S99+:::GYPS PA XLENCE EXTRA'
PAC+++999'
EQD+BX++1'
UNT+25+062718588340'
UNZ+1+062718588340'

------=NextPart30015890.623498993961--

by (2.0k points)

2 Answers

+1 vote
 
Best answer

Use MimeBase.ContentType property:

MimeData mime = ... 
mime.ContentType = ContentType.Parse("Application/EDIFACT");

MimeBase.ContentTypeHeader.Name is used to specify "Name" on Content-Type header.

by (276k points)
selected by
Great!

works now.


------=_NextPart_23458411.590303577215
Content-Type: Application/EDIFACT;
 name="testEdiAtt.edi"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
 filename="testEdiAtt.edi"

UNB+UNOA:2+V.O.F. Bla bla bla :ZZ+blbabla.com:ZZ+170627:0510+062718588340++=
ALF'
UNH+062718588340+CLOCKT:003:006:EF'
BGM+493'
DTM+97:20170627:102'
–1 vote

the result should contains something like this:
(i skipped the filename while this also results in the wrong Content-Type)

X-Original-Date: Tue, 27 Jun 2017 05:20:04 +0200
Content-Disposition: attachment;
filename="__4Y90BEQMY.edi"
Content-Type: Application/EDIFACT


Test with FileName results in:

Content-Type: multipart/mixed;
boundary="----=NextPart23458411.159013775632"
MIME-Version: 1.0
Date: Thu, 29 Jun 2017 09:09:40 +0200
Message-ID: b7123123-2e46-4c83-98d8-75213cf64871@mail.dll
Subject: Test mail
To: "" me@somewhere.com
Priority: urgent

------=NextPart23458411.159013775632
Content-Type: text/plain;
charset="utf-8"
Content-Transfer-Encoding: 7bit

------=NextPart23458411.159013775632
Content-Type: application/octet-stream;
name="testEdiAtt.edi"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
filename="testEdiAtt.edi"

UNB+UNOA:2+V.O.F. Bla bla bla :ZZ+blbabla.com:ZZ+170627:0510+062718588340++=
ALF'
UNH+062718588340+CLOCKT:003:006:EF'
BGM+493'
DTM+97:20170627:102'
NAD+BY+999999'
NAD+FLA+74'
NAD+SE+8713783418383:160:9'
LIN+++110252:VBN'
DTM+9:051008:402'
NAD+MF+283234'
RFF+AGJ:2164'
RFF+FAC:1'
RFF+FAN:636941'
RFF+BT:07401178021640000001'
RFF+VN:0741780102164'
QTY+52:25'
QTY+66:1'
PRI+INV:0.480'
IMD++S20+075'
IMD++S21+030'
IMD++S62+EC'
IMD++S99+:::GYPS PA XLENCE EXTRA'
PAC+++999'
EQD+BX++1'
UNT+25+062718588340'
UNZ+1+062718588340'

------=NextPart23458411.159013775632--

by (2.0k points)
...