cancel
Showing results for 
Search instead for 
Did you mean: 

Email IMAP4 -> POP3

Former Member
0 Kudos

according to the example

pls help

https://www.sdn.sap.com/irj/sdn/downloaditem?rid=/library/uuid/b040e6cd-0401-0010-268d-f67cf4904358


try {
		Store store=session.getStore("POP3");
		//Store store = session.getStore("imap4");
		store.connect(host,username,password);
		//Get folder
		Folder folder = store.getFolder("INBOX");
		folder.open(Folder.READ_ONLY);
		//Get Mails
		message = folder.getMessages();

it return a message saying that

"No provider for POP3"

What is the solution for this


public void readInbox( )
  {
    //@@begin readInbox()
	while (! wdContext.nodeEmail().isEmpty()) { 
		wdContext.nodeEmail().removeElement(wdContext.nodeEmail().getElementAt(0) );
	}
	wdContext.nodeEmail().invalidate();    
	Message[] message = new Message[1000];
	IPublicEmailInteractiveFormComp.IEmailElement newEmailNodeElement;
	//Set properties
	
	// @TODO Enter your email server address here by replacing the text in angle brackets.
	String host = "mail.xxx.com";
	// @TODO Enter your email account here by replacing the text in angle brackets.
	String username = "xxx@xxx.com";
	// @TODO Enter your email account password here by replacing the text in angle brackets.
	String password = "xxxx";
	Properties props = new Properties();	
	props.put("mail.smtp.host", host);
	//Set Session
	Session session = Session.getInstance(props, null);
	//Set the store
	try {
		Store store=session.getStore("SMTP");
		//Store store = session.getStore("imap4");
		store.connect(host,username,password);
		//Get folder
		Folder folder = store.getFolder("INBOX");
		folder.open(Folder.READ_ONLY);
		//Get Mails
		message = folder.getMessages();
		//Fill table with mails
		for (int i = 0; i < message.length; i++) 
		{
			if (message<i>.isSet(Flags.Flag.SEEN) == false) 
			{ 
				if (message<i>.getSubject().equals("Travel Request Form"))
				{
					newEmailNodeElement = wdContext.createEmailElement();	  		
					newEmailNodeElement.setFrom(message<i>.getFrom()[0].toString());
					newEmailNodeElement.setSubject(message<i>.getSubject());
					newEmailNodeElement.setSentDate(message<i>.getSentDate().toString());
					//Check for right Attachment
					Object content = message<i>.getContent();
					if ( content != null  && content instanceof Multipart) 
					{
						for (int j = 0 , n = ((Multipart)content).getCount(); j < n; j++) 
						{		
							Part part = ((Multipart)content).getBodyPart(j);
							String disposition = part.getDisposition();
							if ( disposition != null && (disposition.equals(Part.ATTACHMENT) || disposition.equals(Part.INLINE)))
							{
								if (part.getFileName().equals("TravelRequest.pdf")) 
								{
									newEmailNodeElement.setAttachment(true);
									newEmailNodeElement.setContentType(part.getContentType().toString());
									InputStream is = part.getInputStream();
									ByteArrayOutputStream bo = new ByteArrayOutputStream();																
									int c;
									while ((c = is.read()) > -1) bo.write(c);
									byte[] pdfSource = bo.toByteArray();
									newEmailNodeElement.setPdfSource(pdfSource);
									break;	
								}
								else
								{
									newEmailNodeElement.setAttachment(false);	
								}
							}
						}
					}
					wdContext.nodeEmail().addElement(newEmailNodeElement);
				}
			}
		}
		//Close connection
		folder.close(true);
		store.close();		
	} 
	catch (MessagingException e) 
	{
		wdComponentAPI.getMessageManager().reportSuccess(e.getMessage());
		e.printStackTrace();
	} 
	catch (IOException e)
	{
		wdComponentAPI.getMessageManager().reportSuccess(e.getMessage());
		e.printStackTrace();
	} 	
    //@@end
  }

Message was edited by:

yzme yzme

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

use SMTP

Regards, ANilkumar

Former Member
0 Kudos

No provider for SMTP