送信したメールの添付ファイルが受信側で認識されない場合がある
対象製品
Secure iNetSuite for .NET 4.0J
状況
修正済み
詳細
メールに添付ファイルが含まれる場合やHTMLメールなどのマルチパートメッセージが含まれる場合、メールヘッダのContent-Typeにパートの境界文字を設定します。
このとき、本製品のサービスパック6以前では以下のように境界文字をダブルクォーテーションで囲んだ形式で設定していました。
Content-Type: multipart/mixed; boundary="=_NextPart_2036866168"
ところが、サービスパック7では以下のようにダブルクォーテーションで囲まない形式で設定するようになりました。
Content-Type: multipart/mixed; boundary==_NextPart_2036866168
境界文字に "=" が含まれるため、この場合はRFCの仕様上ダブルクォーテーションで囲むのが正しい設定になります。
このためメールサーバーによってはマルチパート部分が認識されず、メールを正しく受信できない可能性や、ご利用のセキュリティソフトによってはメールの添付ファイルが消去された形で受信される場合があります。
このとき、本製品のサービスパック6以前では以下のように境界文字をダブルクォーテーションで囲んだ形式で設定していました。
Content-Type: multipart/mixed; boundary="=_NextPart_2036866168"
ところが、サービスパック7では以下のようにダブルクォーテーションで囲まない形式で設定するようになりました。
Content-Type: multipart/mixed; boundary==_NextPart_2036866168
境界文字に "=" が含まれるため、この場合はRFCの仕様上ダブルクォーテーションで囲むのが正しい設定になります。
このためメールサーバーによってはマルチパート部分が認識されず、メールを正しく受信できない可能性や、ご利用のセキュリティソフトによってはメールの添付ファイルが消去された形で受信される場合があります。
回避方法
この問題はService Pack 8(v4.0.2018.0822)で修正されました。
不具合を修正した最新のサービスパックは、アップデートページ からダウンロードできます。
最新のサービスパックを適用しない場合は、次のいずれかの方法で回避可能です。
方法1. 境界文字から"="を除去する
方法2. 境界文字をダブルクォーテーションで囲む
◎サンプルコード(VB)
◎サンプルコード(C#)
不具合を修正した最新のサービスパックは、アップデートページ からダウンロードできます。
最新のサービスパックを適用しない場合は、次のいずれかの方法で回避可能です。
方法1. 境界文字から"="を除去する
方法2. 境界文字をダブルクォーテーションで囲む
◎サンプルコード(VB)
' msgはDart.Mail.MailMessageオブジェクト
' 境界文字から"="を除去する方法
msg.ContentType.Boundary = msg.ContentType.Boundary.Replace("=", "")
For Each p As Dart.Mail.Part In msg.Parts
If TypeOf p Is Dart.Mail.Multipart Then
p.ContentType.Boundary = p.ContentType.Boundary.Replace("=", "")
End If
Next
' 境界文字をダブルクォーテーションで囲む方法
msg.ContentType.Boundary = """" + msg.ContentType.Boundary + """"
For Each p As Dart.Mail.Part In msg.Parts
If TypeOf p Is Dart.Mail.Multipart Then
p.ContentType.Boundary = """" + p.ContentType.Boundary + """"
End If
Next
' 境界文字から"="を除去する方法
msg.ContentType.Boundary = msg.ContentType.Boundary.Replace("=", "")
For Each p As Dart.Mail.Part In msg.Parts
If TypeOf p Is Dart.Mail.Multipart Then
p.ContentType.Boundary = p.ContentType.Boundary.Replace("=", "")
End If
Next
' 境界文字をダブルクォーテーションで囲む方法
msg.ContentType.Boundary = """" + msg.ContentType.Boundary + """"
For Each p As Dart.Mail.Part In msg.Parts
If TypeOf p Is Dart.Mail.Multipart Then
p.ContentType.Boundary = """" + p.ContentType.Boundary + """"
End If
Next
◎サンプルコード(C#)
// msgはDart.Mail.MailMessageオブジェクト
// 境界文字から"="を除去する方法
msg.ContentType.Boundary = msg.ContentType.Boundary.Replace("=", "");
foreach(Dart.Mail.Part p in msg.Parts)
{
if (p is Dart.Mail.Multipart)
{
p.ContentType.Boundary = p.ContentType.Boundary.Replace("=", "");
}
}
// 境界文字をダブルクォーテーションで囲む方法
msg.ContentType.Boundary = "¥"" + msg.ContentType.Boundary + "¥"";
foreach (Dart.Mail.Part p in msg.Parts)
{
if (p is Dart.Mail.Multipart)
{
p.ContentType.Boundary = "¥"" + p.ContentType.Boundary + "¥"";
}
}
// 境界文字から"="を除去する方法
msg.ContentType.Boundary = msg.ContentType.Boundary.Replace("=", "");
foreach(Dart.Mail.Part p in msg.Parts)
{
if (p is Dart.Mail.Multipart)
{
p.ContentType.Boundary = p.ContentType.Boundary.Replace("=", "");
}
}
// 境界文字をダブルクォーテーションで囲む方法
msg.ContentType.Boundary = "¥"" + msg.ContentType.Boundary + "¥"";
foreach (Dart.Mail.Part p in msg.Parts)
{
if (p is Dart.Mail.Multipart)
{
p.ContentType.Boundary = "¥"" + p.ContentType.Boundary + "¥"";
}
}