Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

sending email using SMTP to Outlook

Hi all,

any one knows how to send email using SMTP from webdynpro application to Outlook. Please reply.

Thank you

Maruthi

replied

Hi

Make sure you maintain you java mail client settings in Visual Admin

use the following code example to send mail messages

Properties props = new Properties();
				props.put("domain", "true");
				Context initialContext = new InitialContext(props);
				Session sess = (Session) initialContext.lookup("java:comp/env/mail/MailSession");
				Session mailSession = Session.getDefaultInstance(sess.getProperties());
				Transport transport = mailSession.getTransport("smtp");
				//MimeMessage message = new MimeMessage(sess);
				MimeMessage message = new MimeMessage(mailSession);
				message.setSubject("Your ERP Portal Certificate");
				message.setFrom(new InternetAddress("portal@portal.com"));
				message.addRecipient(javax.mail.Message.RecipientType.TO, new InternetAddress(userArr.getEmail()));
				//
				// This HTML mail have to 2 part, the BODY and the embedded image
				//
				MimeMultipart multipart = new MimeMultipart("related");
				// first part  (the html)
				BodyPart messageBodyPart = new MimeBodyPart();
				String htmlText ="Dear ERP user , </b>"	;													messageBodyPart.setContent(htmlText, "text/html");
				// add it
				multipart.addBodyPart(messageBodyPart);
				// put everything together
				message.setContent(multipart);
				transport.connect();
				transport.sendMessage(message, message.getRecipients(javax.mail.Message.RecipientType.TO));
				transport.close();
				proxy.gotoPage("umHelpPage");
				uidUserCreatteLog(userArr.getEmail());
			}

Theo

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question