Page tree
Skip to end of metadata
Go to start of metadata

This guide explains how to send an email with your Smartface project.

Sending Email

The Smartface let developers to build an application enables sending emails. The email methods can be reached under "SMF.Net. library". These methods directly use the available email applications which are installed in the device.
The "sendMail" method requires some parameters to work and it has success and failure callback events. 

Parameters

NAMETYPEDESCRIPTON
toStringThe email address that you want to send an email.
ccStringThe email addresses that you want to send the cc (carbon copy) of the email.
bccStringThe email addresses that you want to send the bcc (blind carbon copy) of the email.
titleStringThe title of the email which you will send, it is generally called as subject.
bodyStringThe body of the email, it is generally the message of the email.
attachmentArrayThe attachment of the email, it can be a file, image or any kind of document
onSuccessFunctionThe function that will be called if sendMail succeeds.
onFailureFunctionThe function that will be called if sendMail fails.

Sample

The sample use of sending an email is shown as below :

SMF.Net.sendMail({
	to : "info@smartface.io",
	cc : "",
	bcc : "",
	title : "Test Mail",
	body : "This is test mail.",
	attachment : "",
	onSuccess : function () {
		alert("success");
	},
	onFailure : function () {
		alert("failure");
	}
});

Adding Attachment

Any file can be sent via email. In the sample below we show how to capture a photo and send it via email :

function sendEmailWithPhoto(e) {
	SMF.Multimedia.startCamera({
		cameraType : SMF.Multimedia.CameraType.REAR,
		resolution : SMF.Multimedia.Resolution.LARGE,
		autoFocus : true,
		onStart : function () {}, //do nothing
		onCapture : function (e) {
			var mailImg = new SMF.Bitmap({
					imageUri : e.photoUri,
					onSuccess : function (e) {
						//image details can be shown like
						//alert(e.width + " " + e.height + " " + e.imageUri);
					},
					onError : function (e) {
						alert(lang.applicationError);
					}
				});
			var item = [mailImg]; //item should be an array
			SMF.Net.sendMail({
				to : "info@smartface.io",
				cc : "",
				bcc : "",
				title : "a beautiful photo for you",
				body : "Hi, I captured a nice photo and want to share it with you :)",
				attachment : item,
				onSuccess : function () {
					alert("success");
				},
				onFailure : function () {
					alert("failure");
				}
			});

		},
		onCancel : function () {}, //do nothing
		onFailure : function () {}
		//do nothing
	});
}