Send email with html and images over Sockets
Hi! I'm sending email messages through sockets with html. So far is working great. But now, I need to include images in the html code, like a web page. I don't have any idea on how to do this. Sending image apart from the html code is not big deal, but how to put it in the code. I mean how to make this html code, work:
<table border="0">
<tr>
<td>Image in code</td>
</tr>
<tr>
<img src="what to put here"/>
</tr>
</table>This is the code that I'm using to send the html mail:
StringBuffer retBuff = new StringBuffer();
//BufferedReader msg;
//msg = new BufferedReader(msgFileReader);
smtpPipe = new Socket(mailHost, SMTP_PORT);
smtpPipe.setSoTimeout(120000);
if (smtpPipe == null) {
return retBuff;
inn = smtpPipe.getInputStream();
outt = smtpPipe.getOutputStream();
in = new BufferedReader(new InputStreamReader(inn));
out = new PrintWriter(new OutputStreamWriter(outt), true);
if (inn == null || outt == null) {
retBuff.append("Failed to open streams to socket.");
return retBuff;
String initialID = in.readLine();
retBuff.append(initialID);
retBuff.append("HELO " + localhost.getHostName());
out.println("HELO " + localhost.getHostName());
String welcome = in.readLine();
retBuff.append(welcome);
retBuff.append("MAIL From:<" + from + ">");
out.println("MAIL From:<" + from + ">");
String senderOK = in.readLine();
retBuff.append(senderOK);
for (int i = 0; i < to.length; i++) {
retBuff.append("RCPT TO:<" + to[i] + ">");
out.println("RCPT TO:<" + to[i] + ">");
String recipientOK = in.readLine();
retBuff.append(recipientOK);
retBuff.append("DATA");
out.println("DATA");
out.println("From: Steren <" + from + ">");
out.println("Subject: " + subject);
out.println("Mime-Version: 1.0;");
out.println("Content-Type: text/html; charset=\"ISO-8859-1\";");
//out.println("Content-Type: multipart/mixed; charset=\"ISO-8859-1\";");
//out.println("Content-Transfer-Encoding: 7bit;");
//String line;
//while ((line = msg.readLine()) != null) {
// out.println(line);
out.println(msg);
retBuff.append(".");
out.println(".");
String acceptedOK = in.readLine();
retBuff.append(acceptedOK);
retBuff.append("QUIT");
out.println("QUIT");
return retBuff;
Throw all this away and use one of the numerous existing Java mail packages, such as javax.mail for a start.
Similar Messages
-
Send Email with HTML format in Outlook Macro
I can use the following to send email with HTML format in VBA. I also have created an HTML file. Is there a way to load the file into .HTMLBody to send it as HTML format message?
Set OutlookApp = CreateObject("Outlook.Application")
Set objMail = OutlookApp.CreateItem(olMailItem)
With objMail
.BodyFormat = olFormatHTML
.HTMLBody = "<HTML><BODY>Enter the message text here. </BODY></HTML>"
.Display
End WithTry:
Dim fso As Scripting.FileSystemObject
Dim htmlFile As Scripting.TextStream
Set fso = New Scripting.FileSystemObject
Set htmlFile = fso.OpenTextFile("C:\path\to\my-html-file.htm")
strInsert = htmlFile.ReadAll
then change:
.htmlbody = strInsert
oh, and you need to set a reference to the Scripting runtime in Tools, References.
Diane Poremsky [MVP - Outlook]
Outlook & Exchange Solutions Center
Outlook Tips
Subscribe to Exchange Messaging Outlook weekly newsletter -
How to send Email with Cc and Bcc using MailPackage
Hi ,
we are using Mail Package to send the Email using Mail Adapter.We have a requirement where we need to send Email with Cc and Bcc using Mail Package .
Can we send Cc and Bcc using Mail Package ?
Thanks
Rajesh .HI Rajesh,
There is a standard structure for Receiver Mail adopter which we can get from SAP market Place but it is not provided with CC if u want to use CC then you have to go with Dynamic Configuration.
DynamicConfiguration configuration = (DynamicConfiguration) container.getTransformationParameters().getStreamTransformationConstants.DYNAMIC_CONFIGURATION);
/*any other required fields*/
DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/Mail", "THeaderCC");
configuration.put(key, "ccemail @ test.com");
Regards
Praveen Reddy
Edited by: Maareddy Praveen Reddy on Aug 10, 2011 12:17 PM -
Send email with attachments and change calendar
hi,
2 questions,
first how can i change the datepicker icon? i want to use something slightly fresher that i have, say an image of a calendar for example?
the second question is a bit more ocmplicated.
i ahve used the send email behaviour no prolems at all, however i need to be able to on an existing site i used to build with addt have the ability to email documents that are uploaded by addt behaviours into the site?
so at the moment you can upload, delete and view the documents. the documents are displayed in a repeating table, i need to be able to have checkboxes next to each documents name and when selected when the person clicks the submit button it email the message with documents attached to an address they specify?
any help would be great.
thanksthansk gunter,
i am happy to try figure it out using addt, ill have a go with checkboxes next to the recordset, i could set the ticked value of the checkbox to the name of the document from the recordset and give it a go?
i think it would have been a cool out the box feature, if you can help at all when you can with trying to impliment i would really appreciate it and i think it will definately help other users at the same time.
i have to say i love addt, so sad it is not around as such. i have noticed a few users talking about php5.3 support and just want to let users know i found a site which has the includes file patched:
http://www.interaktonline.info/files/47-ADDT-1.0.1---PHP-5.3-compatibility-patch.html
great site and think that users should have a look at it. not sure if that solves the issues people are having or not. i just stumbled across it and be good if users could keep our heads together to try and keep this great product alive for as long as we can.
anyway i just thought i would share that with you guys.
hope it helps and hope you can help guide me gunter with the email query.
many thanks -
Sending emails with HTML or not?
I am developing an application which will send 1000's of emails and I'm debating on whether or not to send html in the email. I have two questions:
1. Do most email clients support html? Most of the recipients of the emails will be AOL, hotmail/msn, or yahoo clients. Are there any stats on how many people are running clients that don't support html?
2. The emails I send require an embedded image. Can I send an email with an image and it not be a html email? If so, how? A multipart email? If anybody has an example that would be great!
I'd prefer to not use HTML if possible.
Thanks,
JEBHere is a simplified version of the code. I've left out simple variable declarations, methods, and try-catch blocks but they are obivious...
// AQUIRE THE JAVAMAIL SESSION OBJECT
Properties props = new Properties();
props.put("mail.smtp.host", smtpHost);
Session session = Session.getInstance(props, null);
// PREPARE THE MULTIPART MESSAGE
Message message = new MimeMessage(session);
message.setFrom(new InternetAddress(from, personal));
if (bcc != null)
message.setRecipient(Message.RecipientType.BCC, new InternetAddress(bcc));
message.setSubject(subject);
MimeMultipart multipart = new MimeMultipart("alternative");
BodyPart bodyPartText = new MimeBodyPart();
BodyPart bodyPartHtml = new MimeBodyPart();
BodyPart bodyPartImage = new MimeBodyPart();
bodyPartImage.setDisposition(Part.INLINE);
FileDataSource fds = new FileDataSource(photo);
bodyPartImage.setFileName(fds.getName());
bodyPartImage.setDataHandler(new DataHandler(fds));
bodyPartImage.setHeader("Content-ID", "23abc@pc27");
message.setRecipient(Message.RecipientType.TO, new InternetAddress(to));
// THESE METHODS JUST RETURN TEXT OR HTML, RESPECTIVELY
String htmlContent = createHtmlContent();
String textContent = createTextContent();
// SEND A HTML AND TEXT ALTERNATIVE EMAIL FOR THOSE WHO DON'T SUPPORT HTML
bodyPartText.setContent(textContent, "text/plain");
bodyPartHtml.setContent(htmlContent, "text/html");
multipart.addBodyPart(bodyPartHtml ,0);
multipart.addBodyPart(bodyPartImage, 1);
multipart.addBodyPart(bodyPartText, 2);
message.setContent(multipart);
// SEND THE MAIL MESSAGE
Transport.send(message);Hope this helps,
JEB -
Sending email with HTML report through a button
Hi,
I've noticed in APEX 4 there is a default option (through Action Menu -> Download Formats: email) to send an email with report in HTML format...
may I know how to accomplish it using a Button... seems like APEX is using javascript:gReport.email.show(); function to accomplish it but I don't know how to implement it...
Please advice
Thanks in advanceqwe12654 wrote:
GokhanAtil,
I've posted a sample on APEX.ORACLE.COM... LOGIN DETAILS ARE SAME AS ABOVE...
ON the page now I have both the SQL based report and interactive report...
On the top right you may see 2 icons.. one for downloading report in PDF (using SQL Report as the source) and the second for sending email (using interactive report, similar logic as what you've recommended)...
Is there a way I may be able to send report via email, using SQL report as the source (rather than interactive report)...?
You can always use APEX_MAIL to send emails.
http://download.oracle.com/docs/cd/E10513_01/doc/apirefs.310/e12855/apex_mail.htm
or the alternative option would be:
to convert all my SQL reports into interactive, would require a bit of efforts (I'll go with it if the above option is not available)... but would need to know how to download INTERACTIVE reports in PDF, excel and CSV formats using a button ... similar logic to what you've done for sending emails
Thanks again for all your assistanceIt's very easy to make buttons for downloading the interactive reports in HTML, CSV or PDF.
I have created a PDF button and put the link:
http://apex.oracle.com/pls/apex/f?p=40418:11:1316531694094700:PDF
"1316531694094700" is the value of p_instance. You can find it from HTML codes of your page:
<input type="hidden" name="p_instance" value="1316531694094700" id="pInstance">
You can change PDF to CSV or HTMLD (so your visitor download the report in CSV or HTML)
Best Regards,
Gokhan
If this question is answered, please mark appropriate posts as correct/helpful and the thread as closed. Thanks -
Send email with HTML output?
I have A CFM FILE(testing3.cfm):
<cfset month = #URL.Month#>
<cfset year = #URL.Year#>
<CFQUERY>
SELECT .....code..
</CFQUERY>
<HTML>
<table>
<thead>
<tr >
<th>Month</th>
<th>Employee First Name</th>
<th>Employee Last Name</th>
<th>Stars<br/></th>
<cfoutput query="">
<tr >
<TD></TD>
</tr>
</cfoutput>
</table>
--- more code, pretty much the same
</HTML>
I can see this 'report' when i click on the link depending on the year or month.(testing2.cfm) file
This file gets data from a table from every month,
which works good.
I want to be able to send a email of these results to who ever I choose to send it to.
For example not the same people everytime , I would choose who I put in the 'TO' email part.
So maybe there would be a button/link that would open up the email message (outlook) and i
be able to see what is on the html and be able to send it to the people I would like.
Doing my research I have seen I can use 'cfemail' but this doesnt seem like it would be able
to do what I want, only be able to do attachments.I would like to see the report i will send
before I send it out( from the above code i can click on it).
I be thinking maybe I can add a button/link next the the month in 'testing2.cfm', but im not sure if
that would be the best way to do it.
What would be the best way I can approch this? Any tips or articles I can read would help.You could design it such as to be able to view the content and send the mail on the same page. An example follows.
testing2.cfm
1/2014 (a link that takes you to testing3.cfm)
testing3.cfm
<cfsavecontent variable="pageContent">
<cfquery>
</cfquery>
<html>
<body>
<table>
<thead>
<tr >
<th>Month</th>
<th>Employee First Name</th>
<th>Employee Last Name</th>
<th>Stars<br/></th>
etc.
</body>
</html>
</cfsavecontent>
<p>
<!--- Display page content --->
<cfoutput>#pageContent#</cfoutput>
</p>
<p>
<!--- Clicking on this link will re-open the current page, and send mail --->
<a href="testing3.cfm?action=mail">Send mail</a>
</p>
<cfif isdefined("URL.action") and URL.action is "mail">
<cfquery name="getEmailAddresses" datasource="myDSN">
SELECT email FROM myTable
</cfquery>
<cfmail query="getEmailAddresses"
from="[email protected]"
to="#getEmailAddresses.email#"
subject="Information">
Dear colleague,
Here is the information for January 2014.
<cfoutput>#pageContent#</cfoutput>
Regards,
Admin
</cfmail>
<p>The e-mails have been sent!</p>
</cfif> -
Send Email With Attachment And Recordset Recipients
When I try to send an email with an uploaded attachment, then attach it to the email being sent out to a recordset, my server tells me it has exhausted all its memory to send out the file. The pdf is 10 megs and the amount of ram allowed to be used is 256 megs.
The problem is that it seems to be that the way in which it is goign about sending the email to a recordset is that, it combines the attachment for all the email address. So say i have 35 people in the recordset with a 10 meg pdf, turns into 350 of ram.
Has anyone had any experience with this?Consider using UTL_MAIL package:
http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/u_mail.htm
(Note: it's not installed and configured by default, but the scripts are supplied with the Oracle database, see documentation for instructions) -
Can't send email with EDGE and Earthlink ISP
I cannot send email using EDGE. Receiving email is ok. My ISP is Earthlink. I contacted Earthlink support and they admit they don't have a clue. I have trid the setting specified by Iphone users guide, Apple mail setup asst., Apple support docs, Earthlink, etc. Nothing has worked.
Thanks for any helpThanks for everyone's input. For the most part,I got the same suggestions from everyone here,the Apple support docs, the Earthlink support docs, and Earthlink support rep. All to no avail. For others that have this problem.
THE SOLUTION: You must plug in your phone to itunes, uncheck to sync, and eject the iphone. Then mannually setup the acccount as directed by the Apple support docs, same settings as shown in the Earthlink support docs.
This worked for me. -
Sending emails with 5800 and perhaps other phones
I have noticed several people complaining that although they could receive emails on any email address they had set up in the phone, they could not sent a reply via that same email addresses e,g, Tiscali.
A way to overcome this problem is thus - Have a second email address set up on the phone (Yahoo for instance). Now,on receiving an email from say Tiscali; type a reply; then, before sending it, change to the Yahoo account and then send it. Of course, if your normal email account is already Yahoo or some other one which works both ways; you already have no problem.Thank you for your response Mikael.
For the first question, I was able to find the solution in the following blog:
XI Mail Adapter : Dynamically building attachment and message body content using a simple UDF
(I just needed to search with the right set of key words )
The key is to set the "Content Encoding" as "None" in the mail adapter. If this is not done, the mail will be sent with an attachment - untitled.bin containing both the mail body and the attachment text. Also, don't forget to check the "Keep Attachments" checkbox in the mail adapter.
Multiple recipients could be added by separating the email IDs with a Comma. I have used ASMA to set the recipients. -
SEND EMAIL WITH PO AND ATTACHMENT FILES
Hi,
I'm working with MySAP Enterprise 4.7 and I want to send the PO and its attachment vía e-mail, currently only the PO is being sent to the Vendor and the attachment only appears like texts into the "body" of PO. Is there some way to send e-mail with the PO and attachments at the same time??
I attached the document via DMS at position level.
Thanks in advanced for your answer and help!!
Regards,
Blanca Reyeshi
Follow these steps
Basically there are two mail types: Internet mail (external mail) and
SAPOffice mail.
Mail is sent via the output determination in both cases.
If you use the external mail, the message for the purchasing document is
converted into a corresponding text file which is sent to the vendor via
the Internet.
SAPOffice mail is sent only within the R/3 System and has mainly the
function of providing information.
In particular, it is not possible to attach a message (form) for a
purchasing document to a SAPOffice mail.
When using external mail, the following basic settings are required:
1. You must maintain an e-mail address in the address in the vendor
master.
2. The same applies to your own user master. You also have to specify
an e-mail address there in order to identify the sender.
o Note that it is not possible to change the e-mail address of the endor
o You can use a temporary email address in Transaction ME21N.
3. For the output type for default values, a communication strategy
needs to be maintained in the Customizing that supports the e-mail.
You can find the definition of the communication strategy in the
Customizing via the following path: (SPRO -> IMG -> SAP Web
Application Server -> Basic Services -> Message Control -> Define
Communication Strategy). As a default, communication strategy CS01
is delivered. This already contains the necessary entry for the
external communication. Bear in mind that without a suitable
communication strategy it is not possible to communicate with a
partner via Medium 5 (external sending).
4. Use the standard SAP environment (program 'SAPFM06P', FORM routine
'ENTRY_NEU' and form 'MEDRUCK') as the processing routines.
5. In the condition records for the output type (for example,
Transaction MN04), use medium '5' (External send).
6. You can use Transaction SCOT to trigger the output manually. The
prerequisite for a correct sending is that the node is set
correctly. This is not described here, but it must have already been
carried out.
7. To be able to display, for example, the e-mail in Outlook, enter PDF
as the format in the node.
To use the SAPOffice mail, the following basic settings are required:
1. For the output type for default values, a communication strategy
needs to be maintained in the Customizing that supports the e-mail.
You can branch to the maintenance of the communication strategy via
the input help.
2. Use the SAP standard environment (program "RSNASTSO" and FORM
routine "SAPOFFICE_AUFRUF") as the processing routines.
3. In the condition records for the output type (for example,
Transaction MN04), use medium '7' (SAPOffice) and also partner role
'MP' (mail partner).
Additional settings:
Problem:
How can you both change the mail title and text for the sending of a
mail message and maintain a replacement parameter, for example a
document number.
Solution:
1. The replacement routine is maintained in the Customizing for the
output type in the detail screen on the 'General data' tab under
'Replacement of text symbols' (for Release < 4.6B, this can be found
on the 'Mail' tab page).
Program: SAPMM06E
FORM routine: TEXT_SYMBOL_REPLACE
2. Maintain mail title and text.
o If you want to send a purchase order within an R/3 system using
the SAP office, you can maintain both the mail title ('Re:') and
also a mail text in the Customizing for the output type To do
this, select the directory mail title and text for the
corresponding message type.
o If you want to send a purchase order as (external) mail, for
example, to a vendor, you have to maintain the mail title in the
condition record for the output type (for example in Transaction
MN05) on the 'Communication method' tab page. Enter the mail
title in the 'Text for cover page' field. You cannot maintain an
additional mail text.
o Note that the values from the mail title are used to create the
description for the attachment.
3. The replacement parameters must be enclosed by &. Example: You want
to enter the title 'PO number '. For this you have to enter
the following in the Document Title field (Message Customizing ->
sub-option: Mail title and texts) 'PO number &EKKO-EBELN&'
Reward points if helpful
regards
chetan -
Send email with Attachment and Message in Body
Hi All,
I'm sending an email (Receiver Email Adapter) with a Zipped CSV file as an attachment. I used the following modules to achieve this.
1 localejbs/AF_Modules/StrictXml2PlainBean Local Enterprise Bean strict2plain
2 localejbs/AF_Modules/MessageTransformBean Local Enterprise Bean contentType
3 localejbs/AF_Modules/TextCodepageConversionBean Local Enterprise Bean Transform
4 localejbs/AF_Modules/PayloadZipBean Local Enterprise Bean zip
5 sap.com/com.sap.aii.adapter.mail.app/XIMailAdapterBean Local Enterprise Bean mail
Transform Conversion.charset ISO-8859-1
contentType Transform.ContentDispostion attachment;
contentType Transform.ContentType text/plain;charset="UTF-8";name="Attachment.csv"
contentType Transform.Description file
strict2plain DATA.endSeparator \r\n
strict2plain DATA.fieldSeparator ,
strict2plain fieldNames Result
strict2plain recordTypes DATA
zip zip.filenameKey contentType
zip zip.mode zipAll
My problem now is how to put text content in the body? Please help.> My problem now is how to put text content in the body? Please help.
This is not possible with standard.
You have to write an adapter module for this. -
I can send email with hotmail and iCloud but I can't send using the others.
Still able to receive email, the server it's authenticated by password.
The 3G and the Wi-fi connection match with the service provider.I guess you could try but I don't believe Apple can help with activation lock issues. They may, however, be able to determine if the Apple ID belongs to one of you and reset the password for you if you can prove your identity.
You might want to try calling Apple by going to https://expresslane.apple.com; click 'More Products and Services, then 'Apple ID'. In the next page select 'Other Apple ID Topics' then 'Lost or forgotten Apple ID password'. Perhaps they can help determine if it's your ID and reset the password for you (and they probably have more expertise in doing this than the Apple store). -
CRM 2013 Online - sending email with CRM Online and jQuery
Hi,
I have a html page in webresource in a CRM 2013 Online form. There is a button to send an e-mail from the html page. Because this is an embedded html, I will not be able to create a plug-in to trigger 'send an e-mail'. The best bet
is to send an e-mail via javascript.
I found an article about 'Sending email with SharePoint and jQuery',
http://geekswithblogs.net/ThorvaldBoe/archive/2014/07/03/sending-email-with-sharepoint-and-jquery.aspx
Is there a similar Jquery way we can send e-mail from CRM 2013 Online? Thanks.Hello,
Actually you can send email through plugin using Actions feature. Recheck my articles about the feature -
http://a33ik.blogspot.com/search/label/Action
In case you anyway want to send your email directly you should recheck following articles:
http://mileyja.blogspot.com/2012/02/create-email-activity-in-microsoft.html
http://mileyja.blogspot.com/2012/02/send-email-synchronously-in-microsoft.html
Dynamics CRM MVP/ Technical Evangelist at
SlickData LLC
My blog -
Sending emails with both body and attachment to multiple recipients
I have a requirement to send email with body and attachment to multiple recipients.
Body of the email is a standard text. It is a proxy-to-mail scenario.
Here is what I've done: (I'm using PI 7.11)
One mapping from Source to Target structure (format of the attachment text file)
Second mapping from Target Structure to Mail Package format.
In the second mapping I'm concatenating the output of first step into "Content" of the Mail Package.
"XIPAYLOAD" is the message protocol used.
The "Keep attachments" option in the Mail adapter allows only to send "Content" as attachment or as body of the email.
How to send an email with both content and text?
The other problem is even with using ASMA, I can't send email to multiple recipients. I can only do CC and TO for 1 person each - a total of 2. Although I can resolve this by creating mailing lists, it is better if this can be addressed in PI.
Thanks for any input you can provide!
Edited by: crazylad on Jan 18, 2012 3:39 PMThank you for your response Mikael.
For the first question, I was able to find the solution in the following blog:
XI Mail Adapter : Dynamically building attachment and message body content using a simple UDF
(I just needed to search with the right set of key words )
The key is to set the "Content Encoding" as "None" in the mail adapter. If this is not done, the mail will be sent with an attachment - untitled.bin containing both the mail body and the attachment text. Also, don't forget to check the "Keep Attachments" checkbox in the mail adapter.
Multiple recipients could be added by separating the email IDs with a Comma. I have used ASMA to set the recipients.
Maybe you are looking for
-
I have a particular microphone that is about 8-0 inches in length...it sits on a very small stand, and just plugs into the back of the PC where the mic jack is. I think it is to be used with a web cam, so people can hear the person on the other side
-
How can I keep a kind of global object (Singleton) in App Server?
Hi, I am working with Application Server Platform Edition 8. I want to have a object on the App Server which will have only single instance. The instance will be available to all objects(ejbs) in the server.
-
Adobe CS4 crashes in OS X Mavericks
Photoshop CS4 crashes every time I attempt to manipulate layers. Additionally after a reinstall it will no longer accept my serial number [I have previously reinstalled without problems]. Is this a compatibility issue? are there workarounds for this?
-
Dbms_job.submit paarmeters
hi, i want to call one procedure using dbms_job.submit.this procedure should run twice a day.what are teh values i have to pass to next_date parameter, interval parameter to dbms_job.submit
-
Horizontal menu bar - increase the height and center the vertical treat position.
I am using SpryMenuBarHorizontal.css and want to increase the height of a horizontal menu bar 20 28px and have the menu names move to be centered vertically, rather than be aligned at the top. Can anyone help me figure out how to do this?