|
AdobeBridgeCS5SDK | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Object | +--BasicEmailer
Shows how to use the Socket object to send emails with attachments from Bridge.
This example uses the Socket object to send an email with multiple attachments, by writing to an SMTP server. Attachments are sent as binary data, encoded into Base64 encoding.
This sample sends a single email message at a time, and blocks the main thread in Bridge until the message has been sent. You should select small files (under 100Kb) to send. For a non-blocking example, suitable for sending larger files, see BackgroundEmailer.jsx
Note that this sample is a demonstration of a technique; it may not run as expected with
all mail servers, and is not intended to be a robust mail client.
See:
Field Summary | |
String |
boundary
The boundary for attachments |
String |
mailServerName
The host address for the mail server, for example mail.adomainname.com - NOTE: You must customize this with your own host address value. |
String |
message
The body text of the message |
Socket |
password
The password for the username - NOTE: You must customize this with your own password value. |
int |
POP
The port number for the POP server, for example port 110 - NOTE: You may need to customize this with your own port number. |
String |
recipient
The address the email will be sent to, the receiver of the email - NOTE: You must customize this with your own recipient address. |
String |
requiredContext
The context in which this sample can run. |
String |
sender
The senders email address, for example testemail |
int |
SMTP
The port number for the SMTP server, for example port 25 - NOTE: You may need to customize this with your own port number. |
Socket |
socket
The socket object which this object uses to write to the wire |
String |
subject
The subject of the email |
String |
username
The username, not necessarily the email address, to authorize with, for example testemail |
Constructor Summary | |
BasicEmailer()
|
Method Summary | |
void
|
addAttachment()
Adds attachments to the email being sent |
void
|
authorise()
Authorizes a username against POP3 |
void
|
buildMessage()
Constructs a simple message for the body of the email showing which files are attached. |
Boolean
|
canRun()
Determines whether snippet can be run in the current context. |
Object
|
close()
Closes the socket that was used to transmit data |
Boolean
|
connect(host, port)
Attempts to open a socket and connect to a host and port. |
Boolean
|
doCommand(cmd, type)
Carries out either an SMTP or a POP command. |
String
|
encodeAttachment(binaryString)
Accepts a string representing a binary file and encodes it as base64, to allow attachments to be sent via email |
Boolean
|
run()
Functional part of this snippet. |
Boolean
|
send()
Sends the email and attachments by connecting to the server and authorizing via POP. |
Field Detail |
String boundary
String mailServerName
String message
Socket password
int POP
String recipient
String requiredContext
String sender
int SMTP
Socket socket
String subject
String username
Constructor Detail |
BasicEmailer()
Method Detail |
void addAttachment()
void authorise()
void buildMessage()
Boolean canRun()
Object close()
Boolean connect(host, port)
host
- The host name string of the server to connect to
port
- The port number to connect on, an integer
Boolean doCommand(cmd, type)
cmd
- The command to be written to the socket
type
- One of 'pop' or 'smtp'
String encodeAttachment(binaryString)
binaryString
- The string to encode
Boolean run()
Boolean send()
|
AdobeBridgeCS5SDK | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |