Code: NetMapiErrorCode;
The Code property returns the code of the error that occurred while email message sending.
Sub Main;
Var
Msg: INetMapiMessage;
Client: INetMapiClient;
Attach: INetMapiAttachment;
Begin
Try
Client := New NetMapiClient.Create;
Msg := New NetMapiMessage.Create;
Msg.From_ := "ivanov@server.ru";
Msg.To_.Add("petrov@mail.ru");
Msg.Body := "Photo - Image.bmp";
Msg.Subject := "Photo";
Attach := Msg.Attachments.Add;
Attach.Name := "Photo";
Attach.Path := "c:\Image.bmp";
Client.Message := Msg;
Client.Send;
Except On e: NetMapiException Do
Debug.WriteLine("The email message sending error");
Debug.WriteLine("Error code: " + e.Code.ToString);
End Try;
End Sub Main;
After executing this example the email is sent using the application installed in the operating system and used as a default mail client. The Image.bmp file is attached to the letter. This file is named Photo in the list of attachments. In case an error occurs on the mail message sending, the corresponding message and the error code is displayed in the development environment console.
See also: