Android™ Requires Chilkat v11.0.0+
Android™
Send an email with a Bcc recipient using SMTP (live send)
See more Email Object Examples
Live send. Load the previously prepared with-attachments.eml, add a Bcc recipient, and pass the Email to MailMan.SendEmail. For a real test, use a relay you control, replace the sample sender and recipients (including the Bcc address) with test mailboxes, and obtain credentials from your application’s secret store.
Chilkat Android™ Downloads
// Important: Don't forget to include the call to System.loadLibrary
// as shown at the bottom of this code sample.
package com.test;
import android.app.Activity;
import com.chilkatsoft.*;
import android.widget.TextView;
import android.os.Bundle;
public class SimpleActivity extends Activity {
private static final String TAG = "Chilkat";
// Called when the activity is first created.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
boolean success = false;
// Assumes Chilkat is unlocked. See Global Unlock Sample.
CkEmail email = new CkEmail();
success = email.LoadEml("with-attachments.eml");
if (success != true) {
Log.i(TAG, email.lastErrorText());
return;
}
// Enable this option before adding a blind recipient to the message.
email.put_UncommonOptions("NoBccHeader");
success = email.AddBcc("Bcc recipient","bcc@example.net");
if (success != true) {
Log.i(TAG, email.lastErrorText());
return;
}
CkMailMan mail = new CkMailMan();
mail.put_SmtpHost("smtp.example.com");
mail.put_SmtpPort(465);
mail.put_SmtpSsl(true);
mail.put_RequireSslCertVerify(true);
mail.put_SmtpUsername("MAIL_USER");
mail.put_SmtpPassword("MAIL_PASSWORD");
success = mail.SendEmail(email);
if (success != true) {
Log.i(TAG, mail.lastErrorText());
return;
}
Log.i(TAG, "The SMTP relay accepted the message.");
success = mail.CloseSmtpConnection();
if (success != true) {
Log.i(TAG, mail.lastErrorText());
return;
}
}
static {
System.loadLibrary("chilkat");
// Note: If the incorrect library name is passed to System.loadLibrary,
// then you will see the following error message at application startup:
//"The application <your-application-name> has stopped unexpectedly. Please try again."
}
}