これを行う正しい方法は、MAPI を使用することです
これはVB6のコードです:
Public Function MailtoWithAttachment(ByVal Recipient As String, ByVal Subject As String, ByVal Body As String, ByVal Attachment As String) As Boolean
Dim Message As MAPIMessage
Dim RecipientA() As Byte
Dim Recipients(0) As MapiRecip
Dim AttachmentA() As Byte
Dim Attachments(0) As MapiFile
Dim SubjectA() As Byte
Dim BodyA() As Byte
Dim Result As Long
'Set the recipient
RecipientA = StrConv(Recipient & vbNullChar, vbFromUnicode)
Recipients(0).lpName = VarPtr(RecipientA(0))
Recipients(0).RecipClass = MAPI_TO
Message.RecipCount = 1
Message.lpRecips = VarPtr(Recipients(0))
'Add the attachment
AttachmentA = StrConv(Attachment & vbNullChar, vbFromUnicode)
Attachments(0).lpPathName = VarPtr(AttachmentA(0))
Attachments(0).Position = -1
Message.FileCount = 1
Message.lpFiles = VarPtr(Attachments(0))
'Subject
SubjectA = StrConv(Subject & vbNullChar, vbFromUnicode)
Message.lpSubject = VarPtr(SubjectA(0))
'And body
BodyA = StrConv(Body & vbNullChar, vbFromUnicode)
Message.lpNoteText = VarPtr(BodyA(0))
'Try and send the email
Result = MAPISendMail(0, 0, ByVal VarPtr(Message), MAPI_DIALOG, 0&)
'Return false if there was a problem (ignoring canel)
MailtoWithAttachment = Result = 0 Or Result = 1
End Function
これはMAPI32.basの宣言を使用し、ユニコードから ANSI への変換と構造体のポインターを多用します。
すべてのメール クライアントがこれをサポートしているわけではないことに注意してください。唯一の解決策は、それぞれにカスタム インターフェイスを使用することです。