Take a survey

Developing Components > Creating Your First Component > Testing your component > Invoking the EmailService using a .NET application

Invoking the EmailService using a .NET application
You can create a .NET client application that can invoke the EmailService and send email messages. The EmailService, like other services in LiveCycle ES, can be invoked by using a web service. LiveCycle ES uses the component.xml file and creates a WSDL for the service when the service is deployed. As a result, you can create a .NET client assembly that consumes the EmailService WSDL and use the client assembly to send email messages. For information, see Developing the .NET client assembly.
Note: To invoke a service using a .NET application, it is strongly recommended that you are familiar with invoking LiveCycle ES using web services. For information, see Invoking LiveCycle ES Using Web Services.
The following illustration shows the client email application that can invoke the EmailService and send email messages.
The following table lists the controls that are part of this client application.
 
The following C# code example invokes the EmailService and sends an email message. This code is located in the buttonSend_Click method.
Example: Invoking the Email service using a .NET application
private void buttonSend_Click(object sender, System.EventArgs e)
{
try
		{
			//Create a EmailServiceService object
			EmailServiceService emailClient = new EmailServiceService();
			emailClient.Credentials = new System.Net.NetworkCredential("administrator", "password");
		
			//Get the user-specified values 
			String toValue = textBoxTo.Text;
			String ccValue = textBoxCC.Text;
			String bccValue = textBoxBCC.Text;
			String subjectValue = textBoxSubject.Text;
			String mimeValue = comboBoxMime.Text; 
			String fileAttachment = textBoxAttachment.Text;
			String message = textBoxMessage.Text;
 
			//Create a BLOB object to store the file attacment
			BLOB inFile = new BLOB();
				
			FileStream fs = new FileStream(fileAttachment, FileMode.Open);
			
			//Get the length of the file stream 
			int len = (int)fs.Length; 
			byte[] ByteArray=new byte[len];
 
			//Populate the byte array with the contents of the FileStream object
			fs.Read(ByteArray, 0, len);
			inFile.binaryData = ByteArray; 
 
			//Send the email message
			emailClient.send(toValue,
				ccValue,
				bccValue,
				subjectValue,
				mimeValue,
				message,
				fileAttachment,
				inFile); 
			
			MessageBox.Show("The email message was successfully sent");
			}
			catch (Exception ee)
			{
				Console.WriteLine("An unexpected exception was encountered." + ee.StackTrace);
			}
}
Note: Notice that the EmailServiceService object’s send method contains parameters that correspond to the parameters specified in the send method that is defined in the EmailService interface. For information, see Defining the service interface.
 

 

Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/livecycle/es/sdkHelp/programmer/sdkHelp/componentCreating.158.17.html