How to avoid attachment with code e-mail

Hello

I wrote a code for sending email notification. Code works very well as e-mail is triggered as expected, but when the mail is received an attachment called attzurlm.dataccompanies. give pointers how to remove this attachment.

PFB code
public String sendEmail (list < String > recipientList, subject to the String, String message, String to, String cc, String logoPath, Logger LOGGER) {}

try {}
functionName = "sendEmail ()"; "
Set the smtp address host
Properties props = new Properties ();
Useful util = new Utils();
Extraction of search values
tcLookupOperationsIntf lookupIntf = (tcLookupOperationsIntf.class) Platform.getService;
String smtpHost = util.getLookUpValueByKey ("LookUp.EmailInfo", "CG_EMAIL_SERVER", lookupIntf, LOGGER);
LOGGER.debug (functionName + "SMTP host name:" + smtpHost);
props.put ("mail.smtp.host", smtpHost);
props.put ("mail.smtp.auth", "false");

create properties and get the default value of Session
A session = Session.getDefaultInstance (propellers, null);
session.setDebug (debug);

create a message
Message msg = new MimeMessage (session);

Check if the cc is required
If (cc.length ()! = 0) {}
InternetAddress ccAddress = new InternetAddress (cc);
msg.setRecipient (RecipientType.CC, ccAddress);
}

set the from and to address
InternetAddress addressFrom = new InternetAddress (from);

msg.setFrom (addressFrom);

InternetAddress [] addressTo = new InternetAddress [recipientList.size ()];

for (int iCountMail = 0; iCountMail < recipientList.size (); iCountMail ++)
{
addressTo [iCountMail] = new InternetAddress (recipientList.get (iCountMail));
}
msg.setRecipients (Message.RecipientType.TO, addressTo);

Definition of the object and the Content Type
msg.setSubject (subject);
msg.setText (message);
MimeMultipart multipart = new MimeMultipart ("related");
first part (html)
BodyPart messageBodyPart = new MimeBodyPart();
String htmlText = "< br >" + message + "< BR > < BR > < P align =------"left\"> ' + ' < br > < img src =------"cid:image\"> < br > < br > ' + '< /P >";
messageBodyPart.setContent (htmlText, "text/html");
multipart.addBodyPart (messageBodyPart);
messageBodyPart = new MimeBodyPart();
MSDS of DataSource = null;
try {}
SDS = new FileDataSource (logoPath);
} catch (Exception exe) {}
LOGGER.debug ("function: + sendEmial: logofile path is missing" + logoPath);
}
messageBodyPart.setDataHandler (new DataHandler (SDS));
messageBodyPart.setHeader ("Content-ID", "< image >");
multipart.addBodyPart (messageBodyPart);

put it all together
msg.setContent (multipart);

Transport.Send (MSG);
LOGGER.info ("Email sent to the recipient:" + recipientList);
} catch {(MessagingException msgExc)
LOGGER.error (functionName + "error occurred when sending email:" + msgExc);
msgExc.printStackTrace ();
return to 'ERROR ';

} catch (Exception exception) {}
LOGGER.error (functionName + "error occurred when sending email:" + exception);
exception.printStackTrace ();
return to 'ERROR ';
}
Return "SUCCESS";
}

Check if the sons of logoPath to attzurlm.dat, if so, attach the file.

Tags: Java

Similar Questions

Maybe you are looking for