Sending an email with html tags in it using apex_mail.send
Hello,
I am using APEX_MAIL.SEND to send emails from my apex applications.
now I need the email body to have html features: bold, underline, colors etc.
If I use regular html tags, they show up in the email.
How can this be done?
Thanks
Rani
Hi, try
p_body_html
and it should display just fine :)
Similar Messages
-
Please help to send an email with html page in body
I need an html page on the body of an email to send an email blast to our customers.
HTML Emails can be a bit tricky. You can design them in Dreamweaver, but you really shouldn't send mass email through your personal email account (or your company account). That could get you blacklisted by corporate spam filters and make your email addresses pretty much useless.
For mass email campaigns (over a few hundred email addresses) I use http://www.icontact.com.
You can build the email right through their site (without DW) or you can import your html from DW to their service.
Some things to keep in mind with HTML email...
1. Use absolute links to images and files on a server you control
2. Use a limited amount of inline css (no external or embedded css)
3. Use table based layouts, css support is spotty at best with email clients
4. The <head> will be stripped from a number of email clients, don't rely on anything between the <head> tags making it to your recipients
5. Don't use an image-only email. HTML text is very important to keep it from being labeled spam, make the images secondary to the message, many email clients will not download images without the user's say-so
6. Include an opt-out link so people can get off your list
There are more things to watch out for, but those are the big ones. Here is some more good info: http://alt-web.com/Articles/HTML-Emails.shtml -
worked with cox.net for an hour trying to correct the problem. Something in FF is causing the problem. come up general exception details. java.lang.classformaterror: Incompatible magic value 168430090 in class file.
try
The Reset Firefox feature can fix many issues by restoring Firefox to its factory default state while saving your essential information.
Note: ''This will cause you to lose any Extensions, Open websites, and some Preferences.''
To Reset Firefox do the following:
#Go to Firefox > Help > Troubleshooting Information.
#Click the "Reset Firefox" button.
#Firefox will close and reset. After Firefox is done, it will show a window with the information that is imported. Click Finish.
#Firefox will open with all factory defaults applied.
Further information can be found in the [[Reset Firefox – easily fix most problems]] article.
Did this fix your problems? Please report back to us!
Thank you. -
I have a problem with generating HTML based email.
BPEL code example:
<copy>
<from expression="'%lt;HTML%gt;%lt;BODY%gt;%lt;B%gt;Hello World! %lt;/B%gt;%lt;/BODY%gt;%lt;/HTML%gt;'"/>
<to variable="mailRequestOne" part="payload" query="/mail:mailMessage/mail:content/mail:multiPart/mail:bodyPart[1]/mail:content"/>
</copy>
It would send email:
%lt;HTML%gt;%lt;BODY%gt;%lt;B%gt;Hello World!%lt;/B%gt;%lt;/BODY%gt;%lt;/HTML%gt;
Any idea how to send an email with HTML code?
ps: replace % by &Not sure what you expect. Your URL is absolute and pointing to a local file resource. It's not a proper relative HTML link. Beyond that it's toatlly unclear how you actually plan to load your image and where they are hosted, so nobody can tell you anything. Either way, there is an obviously painful lack of understanding of even the most basic web techniques, so the best advise anyone would give you is to spend some time with a web search and actualyl learn some of that stuff...
Mylenium -
Email with html body and a pdf attachment
Hi,
i try to send a email with html body and one attach in pdf
in release 4.6c using the SO_DOCUMENT_SEND_API1.
I've put the html in the txt table and the pdf in bin table but i obtain the following situation:
1) with only the html in the body i see a right email in html
2) with the html body AND the pdf attach i obtain a empty mail with two attach.
what can i do ? I's possible to do this.
Thanks in advance.Contact my basis guy is a problem !!
maybe a need a function similar to SX_OBJECT_CONVERT_RAW_TXT to convert raw (containing html text) into real html ?
my view V_SXCONV contain:
ALI HTM 2 SX_OBJECT_CONVERT_ALI_HTM
ALI PS 4 SX_OBJECT_CONVERT_ALI_PRT
ALI RAW 1 SX_OBJECT_CONVERT_ALI_RAW
ALI TXT 2 SX_OBJECT_CONVERT_ALI_TXT
ICS RAW 8 SX_OBJECT_CONVERT_ICS_RAW
INT RAW 8 SX_OBJECT_CONVERT_INT_RAW
OBJ HTM 2 SX_OBJECT_CONVERT_OBJ_HTM
OTF PCL 3 SX_OBJECT_CONVERT_OTF_PRT
OTF PDF 1 SX_OBJECT_CONVERT_OTF_PDF
OTF PS 2 SX_OBJECT_CONVERT_OTF_PRT
OTF RAW 9 SX_OBJECT_CONVERT_OTF_RAW
RAW SCR 6 SX_OBJECT_CONVERT_RAW_SCR
RAW TXT 7 SX_OBJECT_CONVERT_RAW_TXT
SCR OTF 1 SX_OBJECT_CONVERT_SCR_OTF
TXT INT 7 SX_OBJECT_CONVERT_TXT_INT
URL HTM 2 SX_OBJECT_CONVERT_OBJL_HTM
thanks a lot. -
Issue in sending the email with XL attachment in ECC version
Hi,
I have an issue with sending the email with XL attachment. My program is sending a mail to the receiver with XLS as attachment. Recently we have migrated from 4.6B to ECC version. Same code was worked in 4.6B.But it is not working in ECC version.When i try to open the attachment, i get a Dialog Box with the following message
"The file is not in a recognizable format.
1. if you know the file is from another program whih is incompatible with Microsoft excel,click cancel,then open this file in its original application
2.If you suspect the file is damaged, click help for more information about solving theproblem.
3.if you still want to see what text is contained in the file, click OK.Then click the text import wizard. "
when i click OK, the excel sheet is opening with all required data.
Can anyone kindly tell me why this is happening.
I am also attaching part of the coding related to this requirement.
*& Form BUILD_XLS_DATA_TABLE
text
--> p1 text
<-- p2 text
FORM build_xls_data_table.
DATA: w_total(13),
w_clabs(13),
w_cinsm(13),
w_ceinm(13),
w_cretm(13),
w_cspem(13),
w_cumlm(13),
w_exp_date(8),
w_v_totalp(13),
w_min_rem(8),
w_ersda(10),
w_hsdat(10),
w_vfdat(10),
w_ship_date(10),
w_plnmg(13),
w_mhdrz(4).
CLEAR: w_total, w_clabs, w_cinsm, w_ceinm, w_cspem, w_exp_date,
w_v_totalp, w_min_rem, w_ersda, w_hsdat, w_vfdat, w_ship_date,
w_plnmg, w_mhdrz.
w_total = it_batch1-total.
w_clabs = it_batch1-clabs.
w_cinsm = it_batch1-cinsm.
w_ceinm = it_batch1-ceinm.
w_cspem = it_batch1-cspem.
w_cumlm = it_batch1-cumlm.
w_cretm = it_batch1-cretm.
w_exp_date = it_batch1-exp_date.
w_v_totalp = it_batch1-v_totalp.
w_min_rem = it_batch1-min_rem.
w_plnmg = it_batch1-plnmg.
w_mhdrz = it_batch1-mhdrz.
CONCATENATE it_batch1-ersda6(2) it_batch1-ersda4(2)
it_batch1-ersda+0(4) INTO w_ersda SEPARATED BY '.'.
CONCATENATE it_batch1-hsdat6(2) it_batch1-hsdat4(2)
it_batch1-hsdat+0(4) INTO w_hsdat SEPARATED BY '.'.
CONCATENATE it_batch1-vfdat6(2) it_batch1-vfdat4(2)
it_batch1-vfdat+0(4) INTO w_vfdat SEPARATED BY '.'.
CONCATENATE it_batch1-ship_date6(2) it_batch1-ship_date4(2)
it_batch1-ship_date+0(4) INTO w_ship_date SEPARATED BY '.'
CONCATENATE
it_batch1-werks it_batch1-mtart it_batch1-matnr it_batch1-maktg
it_batch1-prdha it_batch1-prctr it_batch1-ktext it_batch1-dispo
it_batch1-charg it_batch1-lgort it_batch1-herkl w_clabs
w_cinsm w_ceinm w_cretm w_cspem
w_cumlm w_total it_batch1-meins it_batch1-v_spr_unit
w_v_totalp it_batch1-waers w_plnmg it_batch1-meins
w_ersda w_hsdat w_vfdat w_exp_date
w_ship_date w_mhdrz w_min_rem it_batch1-zlifer
it_batch1-doknr it_batch1-dokar it_batch1-doktl it_batch1-dokvr
INTO L_STRING SEPARATED BY CON_TAB.
INTO l_string SEPARATED BY cl_abap_char_utilities=>horizontal_tab.
WHILE l_string <> space.
CALL FUNCTION 'TEXT_SPLIT'
EXPORTING
length = 255
text = l_string
as_character = 'X'
IMPORTING
line = it_attach
rest = l_string.
IF l_string = space.
CONCATENATE IT_ATTACH CON_CRET INTO IT_ATTACH.
CONCATENATE it_attach cl_abap_char_utilities=>cr_lf INTO it_attach.
APPEND it_attach.
CLEAR it_attach.
ELSE.
APPEND it_attach.
CLEAR it_attach.
ENDIF.
ENDWHILE.
move l_string to it_attach .
CONCATENATE it_attach cl_abap_char_utilities=>cr_lf INTO it_attach.
APPEND it_attach.
CLEAR it_attach.
ENDFORM. " BUILD_XLS_DATA_TABLE
*& Form SEND_FILE_AS_EMAIL_ATTACHMENT
text
--> p1 text
<-- p2 text
FORM send_file_as_email_attachment.
DATA:w_length TYPE i.
DATA: w_cnt TYPE i,
w_sent_all(1) TYPE c,
w_doc_data LIKE sodocchgi1,
gd_error TYPE sy-subrc,
gd_reciever TYPE sy-subrc,
t_attachment LIKE solisti1 OCCURS 0 WITH HEADER LINE.
Fill the document data.
w_doc_data-doc_size = 1.
Populate the subject/generic message attributes
w_doc_data-obj_langu = sy-langu.
w_doc_data-obj_name = 'SAPRPT'.
w_doc_data-obj_descr = text-034 .
w_doc_data-sensitivty = 'F'.
Fill the document data and get size of attachment
CLEAR w_doc_data.
DESCRIBE TABLE it_attach LINES w_cnt.
DESCRIBE TABLE it_message LINES w_cnt.
READ TABLE it_message INDEX w_cnt.
w_length = STRLEN( it_attach ).
w_doc_data-doc_size =
( w_cnt - 1 ) * 255 + STRLEN( it_message ).
w_doc_data-obj_langu = sy-langu.
w_doc_data-obj_name = 'SAPRPT'.
w_doc_data-obj_descr = text-034.
w_doc_data-sensitivty = 'F'.
CLEAR t_attachment.
REFRESH t_attachment.
t_attachment[] = it_attach[].
describe the body of the message
CLEAR t_packing_list.
REFRESH t_packing_list.
t_packing_list-transf_bin = space.
t_packing_list-head_start = 1.
t_packing_list-head_num = 0.
t_packing_list-body_start = 1.
***Start of changes by 501507008 on 29.01.2009
t_packing_list-obj_descr = 'MAIL BODY'.
***End of changes by 501507008 on 29.01.2009
DESCRIBE TABLE it_message LINES t_packing_list-body_num.
t_packing_list-doc_type = 'RAW'.
APPEND t_packing_list.
Create attachment notification
t_packing_list-transf_bin = 'X'.
t_packing_list-head_start = 1.
t_packing_list-head_num = 1.
t_packing_list-body_start = 1.
DESCRIBE TABLE t_attachment LINES t_packing_list-body_num.
t_packing_list-doc_type = 'XLS'.
t_packing_list-obj_descr = text-034.
t_packing_list-obj_name = 'filename'.
t_packing_list-doc_size = t_packing_list-body_num * 255.
APPEND t_packing_list.
Add the recipients email address
CLEAR t_receivers.
REFRESH t_receivers.
LOOP AT it_adr6.
t_receivers-receiver = it_adr6-smtp_addr.
t_receivers-rec_type = 'U'.
t_receivers-com_type = 'INT'.
t_receivers-notif_del = 'X'.
t_receivers-notif_ndel = 'X'.
APPEND t_receivers.
ENDLOOP.
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
document_data = w_doc_data
put_in_outbox = 'X'
sender_address = ' '
sender_address_type = ' '
commit_work = 'X'
IMPORTING
sent_to_all = w_sent_all
TABLES
packing_list = t_packing_list
contents_bin = t_attachment
contents_txt = it_message
receivers = t_receivers
EXCEPTIONS
too_many_receivers = 1
document_not_sent = 2
document_type_not_exist = 3
operation_no_authorization = 4
parameter_error = 5
x_error = 6
enqueue_error = 7
OTHERS = 8.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = w_doc_data
put_in_outbox = 'X'
commit_work = ' '
IMPORTING
sent_to_all =
new_object_id =
tables
packing_list = t_packing_list
contents_bin = t_attachment
contents_txt = it_message
receivers = t_receivers
contents_hex =
object_para =
object_parb =
exceptions
too_many_receivers = 1
document_not_sent = 2
document_type_not_exist = 3
operation_no_authorization = 4
parameter_error = 5
x_error = 6
enqueue_error = 7
OTHERS = 8.
IF sy-subrc <> 0.
ENDIF.
ENDFORM. " SEND_FILE_AS_EMAIL_ATTACHMENTHi,
could you tell me which opeion should i select in SCOT under INT node. I have tried with diffrent options. but no luck.
SAPscript/Smart Forms - No Conversion
ABAP List - No Conversion
Business Object/Link - No Conversion
RAW Text - No Conversion -
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 -
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 -
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 -
How to send a mail with HTML body from Oracle
Hi Team,
Can somebody guide me how to send a mail with HTML body from oracle.
Here is the piece of code i am trying to send a mail.
procedure SEND_MAIL is
cursor c_1 is select * from table_name;
l_mail_id varchar2(40);
-- ls_mailhost VARCHAR2(64) := Mailhost;
ls_from VARCHAR2(64) := ‘[email protected]’
ls_subject VARCHAR2(200);
ls_to VARCHAR2(64);
l_mail_conn UTL_SMTP.connection;
ls_left_menu_name VARCHAR2(64);
ll_emp_num number(8);
begin
for i in c_1 loop
begin
l_mail_conn := UTL_SMTP.OPEN_CONNECTION('IP');
UTL_SMTP.HELO(l_mail_conn, 'IP');
UTL_SMTP.MAIL(l_mail_conn, LS_FROM);
UTL_SMTP.RCPT(L_mail_conn, LS_TO);
UTL_SMTP.DATA(l_mail_conn,'From: ' ||ls_from || utl_tcp.crlf ||
'To: ' ||ls_to || utl_tcp.crlf ||
'Subject: ' ||ls_subject|| utl_tcp.crlf);
UTL_SMTP.QUIT(l_mail_conn);
exception
when no_data_found then
null;
when others then
RAISE_APPLICATION_ERROR(-20000, 'Failed to send mail due to the following error: ' || sqlerrm);
end;
end loop;
end;
ThnxHi Nicolas!
Have you tried to set "Output Format" for "RAW Text" to HTM in SCOT.
If HTM is missing in your dropdown-list, you could check out table SXCONVERT2. Copy the line with category T/format TXT, and change the format from TXT to HTM. The existing function
SX_OBJECT_CONVERT__T.TXT does not need to be changed. Now you should be able to choose HTM in SCOT. You will probably need som HTML-tags in your text to make it look good.
Hope this helps!
Regards
Geir -
Hi,
I am using CRM ONLINE 2013.
How to automate below process?
1. On Approval Of Quotation, Run Report.
2. Generate PDF.
3. Send an Email With PDF as attachment.
As i have gone through many forums for this topic, but creating a plugin code for generating Report PDF is not possible in CRM ONLINE.
So, What is the alternate way to do this..?
Thanks.This is my entire code mentioned below:-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script>
<script type="text/javascript">
if (typeof (SDK) == "undefined")
{ SDK = { __namespace: true }; }
SDK.JScriptRESTDataOperations = {
_context: function () {
if (typeof GetGlobalContext != "undefined")
{ return GetGlobalContext(); }
else {
if (typeof Xrm != "undefined") {
return Xrm.Page.context;
else { return new Error("Context is not available."); }
_getServerUrl: function () {
var serverUrl = this._context().getServerUrl()
if (serverUrl.match(/\/$/)) {
serverUrl = serverUrl.substring(0, serverUrl.length - 1);
return serverUrl;
_ODataPath: function () {
return this._getServerUrl() + "/XRMServices/2011/OrganizationData.svc/";
_errorHandler: function (req) {
return new Error("Error : " +
req.status + ": " +
req.statusText + ": " +
JSON.parse(req.responseText).error.message.value);
_dateReviver: function (key, value) {
var a;
if (typeof value === 'string') {
a = /Date\(([-+]?\d+)\)/.exec(value);
if (a) {
return new Date(parseInt(value.replace("/Date(", "").replace(")/", ""), 10));
return value;
Create: function (object, type, successCallback, errorCallback) {
var req = new XMLHttpRequest();
req.open("POST", this._ODataPath() + type + "Set", true);
req.setRequestHeader("Accept", "application/json");
req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
req.onreadystatechange = function () {
if (this.readyState == 4 /* complete */) {
if (this.status == 201) {
successCallback(JSON.parse(this.responseText, SDK.JScriptRESTDataOperations._dateReviver).d);
else {
errorCallback(SDK.JScriptRESTDataOperations._errorHandler(this));
req.send(JSON.stringify(object));
Retrieve: function (id, type, successCallback, errorCallback) {
var req = new XMLHttpRequest();
req.open("GET", this._ODataPath() + type + "Set(guid'" + id + "')", true);
req.setRequestHeader("Accept", "application/json");
req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
req.onreadystatechange = function () {
if (this.readyState == 4 /* complete */) {
if (this.status == 200) {
successCallback(JSON.parse(this.responseText, SDK.JScriptRESTDataOperations._dateReviver).d);
else {
errorCallback(SDK.JScriptRESTDataOperations._errorHandler(this));
req.send();
Update: function (id, object, type, successCallback, errorCallback) {
var req = new XMLHttpRequest();
req.open("POST", this._ODataPath() + type + "Set(guid'" + id + "')", true);
req.setRequestHeader("Accept", "application/json");
req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
req.setRequestHeader("X-HTTP-Method", "MERGE");
req.onreadystatechange = function () {
if (this.readyState == 4 /* complete */) {
if (this.status == 204 || this.status == 1223) {
successCallback();
else {
errorCallback(SDK.JScriptRESTDataOperations._errorHandler(this));
req.send(JSON.stringify(object));
Delete: function (id, type, successCallback, errorCallback) {
var req = new XMLHttpRequest();
req.open("POST", this._ODataPath() + type + "Set(guid'" + id + "')", true);
req.setRequestHeader("Accept", "application/json");
req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
req.setRequestHeader("X-HTTP-Method", "DELETE");
req.onreadystatechange = function () {
if (this.readyState == 4 /* complete */) {
if (this.status == 204 || this.status == 1223) {
successCallback();
else {
errorCallback(SDK.JScriptRESTDataOperations._errorHandler(this));
req.send();
RetrieveMultiple: function (type, filter, successCallback, errorCallback) {
if (filter != null) {
filter = "?" + filter;
else { filter = ""; }
var req = new XMLHttpRequest();
req.open("GET", this._ODataPath() + type + "Set" + filter, true);
req.setRequestHeader("Accept", "application/json");
req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
req.onreadystatechange = function () {
if (this.readyState == 4 /* complete */) {
if (this.status == 200) {
successCallback(JSON.parse(this.responseText, SDK.JScriptRESTDataOperations._dateReviver).d.results);
else {
errorCallback(SDK.JScriptRESTDataOperations._errorHandler(this));
req.send();
__namespace: true
</script>
<script type="text/javascript">
//Create Email and link it with Order as Regarding field
var Xrm;
var email = new Object();
var ownerID = "";
var CustomerId = "";
if (window.opener) { Xrm = window.opener.Xrm; }
else if (window.parent) { Xrm = window.parent.Xrm; }
//Get ownerid who send email of quotation to customer
function GetOwnerID() {
var owner = Xrm.Page.getAttribute("ownerid").getValue();
ownerID = owner[0].id;
var ownerName = owner[0].name;
var entityType = owner[0].entityType;
GetToEmailGUID();
//Get customerid who receive email of quotation from owner
function GetToEmailGUID() {
var Customer = Xrm.Page.getAttribute('customerid').getValue();
CustomerId = Customer[0].id;
var CustomerName = Customer[0].name;
var entityType = Customer[0].entityType;
//if CustomerId is type of "Account" then get Primary Contact id of that account
if (entityType == "account") {
var contact = Xrm.Page.getAttribute("customerid").getValue();
if (contact === null) return;
var serverUrl = Xrm.Page.context.getClientUrl();
var oDataSelect = serverUrl + "/XRMServices/2011/OrganizationData.svc/AccountSet(guid'" + contact[0].id + "')?$select=PrimaryContactId";
var req = new XMLHttpRequest();
req.open("GET", oDataSelect, false);
req.setRequestHeader("Accept", "application/json");
req.setRequestHeader("Content-Type", "application/json;charset=utf-8");
req.onreadystatechange = function () {
if (req.readyState === 4) {
if (req.status === 200) {
var retrieved = JSON.parse(req.responseText).d;
CustomerId = retrieved.PrimaryContactId.Id;
else {
alert(this.statusText);
req.send();
function CreateEmail() {
GetOwnerID();
email.Subject = "Email with Report Attachment";
//Set The current order as the Regarding object
email.RegardingObjectId = {
Id: Xrm.Page.data.entity.getId(), //Get the current entity Id , here OrderId
LogicalName: Xrm.Page.data.entity.getEntityName()//Get the current entity name, here it will be “salesOrder”
//Create Email Activity
SDK.JScriptRESTDataOperations.Create(email, "Email", EmailCallBack, function (error) { alert(error.message); });
// Email Call Back function
function EmailCallBack(result) {
email = result; // Set the email to result to use it later in email attachment for retrieving activity Id
var activityPartyFrom = new Object();
// Set the From party of the ActivityParty to relate an entity with Email From field
activityPartyFrom.PartyId = {
Id: CustomerId, //"79EBDD26-FDBE-E311-8986-D89D6765B238", // id of entity you want to associate this activity with.
LogicalName: "contact"
// Set the "activity" of the ActivityParty
activityPartyFrom.ActivityId = {
Id: result.ActivityId,
LogicalName: "email"
// Now set the participation type that describes the role of the party on the activity).
activityPartyFrom.ParticipationTypeMask = { Value: 2 }; // 2 means ToRecipients
// Create the from ActivityParty for the email
SDK.JScriptRESTDataOperations.Create(activityPartyFrom, "ActivityParty", ActivityPartyFromCallBack, function (error) { alert(error.message); });
var activityPartyTo = new Object();
// Set the From party of the ActivityParty to relate an entity with Email From field
activityPartyTo.PartyId = {
Id: ownerID, //"79EBDD26-FDBE-E311-8986-D89D6765B238", // id of entity you want to associate this activity with.
LogicalName: "systemuser"
// Set the "activity" of the ActivityParty
activityPartyTo.ActivityId = {
Id: result.ActivityId,
LogicalName: "email"
// Now set the participation type that describes the role of the party on the activity).
activityPartyTo.ParticipationTypeMask = { Value: 1 }; // 1 means Sender
// Create the from ActivityParty
SDK.JScriptRESTDataOperations.Create(activityPartyTo, "ActivityParty", ActivityPartyToCallBack, function (error) { alert(error.message); });
//ActivityParty From Callback
function ActivityPartyFromCallBack(result) {
//ActivityParty To Callback
function ActivityPartyToCallBack(result) {
GetReportId('ABM_Infotech_SalesQuote');
//Create attachment for the created email
function CreateEmailAttachment() {
//get reporting session and use the params to convert a report in PDF
var params = getReportingSession();
//Email attachment parameters
var activitymimeattachment = Object();
activitymimeattachment.ObjectId = Object();
activitymimeattachment.ObjectId.LogicalName = "email";
activitymimeattachment.ObjectId.Id = email.ActivityId;
activitymimeattachment.ObjectTypeCode = "email",
activitymimeattachment.Subject = "File Attachment";
activitymimeattachment.Body = encodePdf(params);
activitymimeattachment.FileName = "Report1.pdf";
activitymimeattachment.MimeType = "application/pdf";
//Attachment call
SDK.JScriptRESTDataOperations.Create(activitymimeattachment, "ActivityMimeAttachment", ActivityMimeAttachmentCallBack, function (error) { alert(error.message); });
//ActivityMimeAttachment CallBack function
function ActivityMimeAttachmentCallBack(result) {
var features = "location=no,menubar=no,status=no,toolbar=no,resizable=yes";
var width = "800px";
var height = "600px";
window.open(Xrm.Page.context.getServerUrl() + "main.aspx?etc=" + 4202 + "&pagetype=entityrecord&id=" + email.ActivityId, "_blank", features);
// To open window which works in outlook and IE both
//openStdWin(Xrm.Page.context.getServerUrl() + "main.aspx?etc=" + 4202 + "&pagetype=entityrecord&id=" + email.ActivityId, "_blank", width,
height, features);
//This method will get the reportId based on a report name that will be used in getReportingSession() function
function GetReportId(reportName) {
var oDataSetName = "ReportSet";
var columns = "ReportId";
var filter = "Name eq '" + reportName + "'";
retrieveMultiple(oDataSetName, columns, filter, onSuccess);
function retrieveMultiple(odataSetName, select, filter, successCallback) {
var serverUrl = Xrm.Page.context.getServerUrl();
var ODATA_ENDPOINT = "/XRMServices/2011/OrganizationData.svc";
var odataUri = serverUrl + ODATA_ENDPOINT + "/" + odataSetName + "?";
if (select) {
odataUri += "$select=" + select + "&";
if (filter) {
odataUri += "$filter=" + filter;
$.ajax({
type: "GET",
contentType: "application/json; charset=utf-8",
datatype: "json",
url: odataUri,
beforeSend: function (XMLHttpRequest) {
XMLHttpRequest.setRequestHeader("Accept", "application/json");
success: function (data) {
if (successCallback) {
if (data && data.d && data.d.results) {
successCallback(data.d.results);
else if (data && data.d) {
successCallback(data.d);
else {
successCallback(data);
error: function (XmlHttpRequest, errorThrown) {
if (XmlHttpRequest && XmlHttpRequest.responseText) {
alert("Error while retrieval ; Error – " + XmlHttpRequest.responseText);
function onSuccess(data) {
reportId = data[0].ReportId.replace('{', ").replace('}', ");
CreateEmailAttachment(); // Create Email Attachment
//Gets the report contents
function getReportingSession() {
var pth = Xrm.Page.context.getServerUrl() + "/CRMReports/rsviewer/reportviewer.aspx";
var retrieveEntityReq = new XMLHttpRequest();
var Id = Xrm.Page.data.entity.getId();
var quotationGUID = Id.replace('{', ""); //set this to selected quotation GUID
quotationGUID = quotationGUID.replace('}', "");
var reportName = "ABM_Infotech_SalesQuote"; //set this to the report you are trying to download
var reportID = "751089AA-74B8-E211-B52F-D8D3855B253B"; //set this to the guid of the report you are trying to download
var rptPathString = ""; //set this to the CRMF_Filtered parameter
var strParameterXML = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'><entity name='quote'><all-attributes /><filter type='and'><condition
attribute='quoteid' operator='eq' uitype='quote' value='" + quotationGUID + "' /> </filter></entity></fetch>";
retrieveEntityReq.open("POST", pth, false);
retrieveEntityReq.setRequestHeader("Accept", "*/*");
retrieveEntityReq.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
rptPathString = "id=%7B" + reportID + "%7D&uniquename=" + Xrm.Page.context.getOrgUniqueName() + "&iscustomreport=true&reportnameonsrs=&reportName="
+
reportName + "&isScheduledReport=false&p:ABMFilteredQuote=" + strParameterXML;
//remove the part starting from &p:salesorderid if your report has no parameters
retrieveEntityReq.send(rptPathString);
var x = retrieveEntityReq.responseText.indexOf("ReportSession=");
var ret = new Array();
ret[0] = retrieveEntityReq.responseText.substr(x + 14, retrieveEntityReq.responseText.indexOf("&", x) - x - 14); //the session id
x = retrieveEntityReq.responseText.indexOf("ControlID=");
ret[1] = retrieveEntityReq.responseText.substr(x + 10, retrieveEntityReq.responseText.indexOf("&", x) - x - 10); //the control id
return ret;
var bdy = new Array();
var bdyLen = 0;
function concat2Bdy(x) {
bdy[bdyLen] = x;
bdyLen++;
function encodePdf(params) {
bdy = new Array();
bdyLen = 0;
var retrieveEntityReq = new XMLHttpRequest();
var pth = Xrm.Page.context.getServerUrl() + "/Reserved.ReportViewerWebControl.axd?ReportSession=" + params[0] +
"&Culture=1033&CultureOverrides=True&UICulture=1033&UICultureOverrides=True&ReportStack=1&ControlID=" + params[1] +
"&OpType=Export&FileName=Public&ContentDisposition=OnlyHtmlInline&Format=PDF";
retrieveEntityReq.open("GET", pth, false);
retrieveEntityReq.setRequestHeader("Accept", "*/*");
retrieveEntityReq.send();
BinaryToArray(retrieveEntityReq.responseBody);
return encode64(bdy);
var StringMaker = function () {
this.parts = [];
this.length = 0;
this.append = function (s) {
this.parts.push(s);
this.length += s.length;
this.prepend = function (s) {
this.parts.unshift(s);
this.length += s.length;
this.toString = function () {
return this.parts.join('');
var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
function encode64(input) {
var output = new StringMaker();
var chr1, chr2, chr3;
var enc1, enc2, enc3, enc4;
var i = 0;
while (i < input.length) {
chr1 = input[i++];
chr2 = input[i++];
chr3 = input[i++];
enc1 = chr1 >> 2;
enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
enc4 = chr3 & 63;
if (isNaN(chr2)) {
enc3 = enc4 = 64;
} else if (isNaN(chr3)) {
enc4 = 64;
output.append(keyStr.charAt(enc1) + keyStr.charAt(enc2) + keyStr.charAt(enc3) + keyStr.charAt(enc4));
return output.toString();
</script>
<script type="text/vbscript">
Function BinaryToArray(Binary)
Dim i
ReDim byteArray(LenB(Binary))
For i = 1 To LenB(Binary)
byteArray(i-1) = AscB(MidB(Binary, i, 1))
concat2Bdy(AscB(MidB(Binary, i, 1)))
Next
BinaryToArray = byteArray
End Function
</script>
</head>
<body>
<input type="button" onclick="CreateEmail();" value="Attach Report" />
</body>
</html> -
Want to send a email with images and text in the body of email in iOS
In iOS, we have written a code to send an email, with embedded images and text in the body of the email ( not attachment) using mail composer. It works well with iOS devices like iPhone and iPad, but does not work in window based OS. Can anybody help. The code is
Thanks James !, do you have an idea how to find the window resource which I belive will be included in our appllication pack.
In above I have missed to copy the code,below is the code. This might help you to help me.
NSMutableString *imgContent = [[[NSMutableString alloc] initWithString:@"<html><body>"] retain];
UIImage *imageData = [UIImage imageNamed:@"Midhun.png"];
NSData *imageDataInBase64 = [NSData dataWithData:UIImagePNGRepresentation(imageData)];
NSString *base64String = [imageDataInBase64 base64EncodedString];
[imgContent appendString:[NSString stringWithFormat:@"<p><b><img src='data:image/png;base64,%@'></b></p>",base64String]];
[imgContent appendString:@"</body></html>"];
MFMailComposeViewController *emailWin = [[MFMailComposeViewController alloc] init];
[emailWin setMessageBody:imgContent isHTML:YES]; -
How to send an email with file attchment
hi,
I have develop one application using HTML DB.In that sending an e-mail facility is also there. I am able to send an email using an the HTMLDB_MAIL.send() procedure. But using this procedure i am unable to attach a file to the mail.Is there any way to send an email with file attachment.
Thanks in Advance.hi,
I have develop one application using HTML DB.In that sending an e-mail facility is also there. I am able to send an email using an the HTMLDB_MAIL.send() procedure. But using this procedure i am unable to attach a file to the mail.Is there any way to send an email with file attachment.
Thanks in Advance. -
Hi.
I'm look for a way to send an Email with an HTML not as an attachment (this I know how to do) but in the email body.
The reason is that sometimes we want to allow the user to see the data without having to open their HTML browser.
I've searched this forum and other and couldn't find anything relevant.
By the way I'm on 4.6c.
thanx in advance.
ayal.Dear Vijay.
I've tried it before I posted this message and also now I copied Rich's code to make sure I haven't left anything.
I get the Email allright, but instead of seing an HTML I see the HTML code itself in the body.
Do I need to do some system configuration like the conversion we do for CSV attachments?
thanx
ayal. -
Tablespace usage report generated with html tags instead of text
Hi ,
We have a unix shell script scheduled to find tablespace usage and sends the report to our mail id.
For the past few weeks(no changes idone in the script) the report is coming with html tags instead of text as below.
</head>
<body>
<p>
<table border='1' width='90%' align='center' summary='Script output'>
<tr>
<th scope="col">
TABLESPACE_NAME
</th>
<th scope="col">
CUR_USE_MB
</th>
<th scope="col">
CUR_SZ_MB
</th>
<th scope="col">
CUR_PRCT_FULL
</th>
<th scope="col">
FREE_SPACE_MB
</th>
<th scope="col">
MAX_SZ_MB
</th>
<th scope="col">
OVERALL_PRCT_FULL
</th>
</tr>
<tr>
<td>
SYSTEM
</td>
<td align="right">
268
</td>
<td align="right">
500
</td>
<td align="right">
54
</td>
Is this any settings issue or anything to be modified in the script.Could you please reply..
Regards,
Bharath.
Edited by: 870384 on Jul 6, 2011 1:17 AMHi Sven W,
Please find the sql below that is generating the tablespace usage report. In the staring of the script markup is set to ON and at the end it is set to OFF.Do you suggest any changes to this..?
SET ECHO OFF
SET PAGES 999
SET MARKUP HTML ON SPOOL ON
col tablespace_name format a15 trunc
col cur_use_mb for 999999999
col cur_sz_mb for 999999999
col free_space_mb for 999999999
col max_sz_mb for 999999999
compute sum of cur_use_mb on report
compute sum of cur_sz_mb on report
compute sum of free_space_mb on report
compute sum of max_sz_mb on report
break on report
spool tablespace.html
select tablespace_name,
round(sum(total_mb)-sum(free_mb),2) cur_use_mb,
round(sum(total_mb),2) cur_sz_mb,
round((sum(total_mb)-sum(free_mb))/sum(total_mb)*100) cur_prct_full,
round(sum(max_mb) - (sum(total_mb)-sum(free_mb)),2) free_space_mb,
round(sum(max_mb),2) max_sz_mb,
round((sum(total_mb)-sum(free_mb))/sum(max_mb)*100) overall_prct_full
from (select tablespace_name,sum(bytes)/1024/1024 free_mb,0 total_mb,0 max_mb from DBA_FREE_SPACE group by tablespace_name
union select tablespace_name,0 current_mb,sum(bytes)/1024/1024 total_mb,sum(decode(maxbytes, 0, bytes, maxbytes))/1024/1024 max_mb
from DBA_DATA_FILES group by tablespace_name) a group by tablespace_name;
select owner,segment_name,segment_type,bytes/(1024*1024) size_m
from dba_segments
where tablespace_name = 'SYSTEM' and segment_name='FGA_LOG$' order by size_m desc;
spool off;
SET MARKUP HTML OFF SPOOL OFF
Maybe you are looking for
-
TS1713 Does my 1-year warranty cover the replacement of a damaged Magsafe adaptor?
The cord on my 85W Magsafe adaptor has been damaged. Does my 1-year warranty cover the replacement of the adaptor?
-
How to get active user data using vba code in excel
Start with this script: http://community.spiceworks.com/scripts/show/1572-list-user-info-in-excel Then add an extra line to get the msDS-UserAccountDisabled attribute, or test for it in an If/Else block.
-
Hello, I have recently bought a Canon LBP6020B laser printer. According to Canon, product has a Mac OS 10.10 driver support, however as I connected the printer to Airport Time Capsule and downloaded driver from the vendor website, it appeared on my p
-
Configuring the PR Scope of List
Dear Gurus I am trying to configure the PR scope of List. Our requirement is that the PR list displayed in ME57 should be able to show the PR item text. Believe new routines would have to be defined to be able to select in customizing. How can this b
-
SAP Data Source for OmniPortlet available for download
What are we Announcing ? The beta release of SAP Data Source for OmniPortlet. SAP data source for OmniPortlet makes it easier than ever before to integrate SAP R/3 systems with Oracle Application Server(OracleAS) Portal. With the new SAP data source,