INetMapiException.Code

Syntax

Code: NetMapiErrorCode;

Description

The Code property returns the code of the error occurred on email message sending.

Example

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 the 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 message. This file is named Photo in the attachments list. If an error occurs on email message sending, the corresponding message and the error code is displayed in the development environment console.

See also:

INetMapiException