I am sending mails in coldfusion as below. But some of my emails being sent are thrown out with the exception below:
<cfif !IsNull(SignatureDetails) && len(trim(SignatureDetails.getDigitalSignature()))>
<!--- Embed digital signature if present via the local file system. --->
<cfset variables.signatureUrl = '../../../urls/files/messages/spreadsheet/rows/columns/' & #SignatureDetails.getDigitalSignature()#>
<cfmailparam file="#ExpandPath('#variables.signatureUrl#')#" contentid="digitalSignature" disposition="inline"/>
</cfif>
And the exception:
object.email.sendTemplateEmail: The resource C:\Data\map\urls\files\messages\spreadsheet\rows\columns\column.jpg was not found. The root cause was: ''.
The correct path should be: C:\Data\urls\files\messages\spreadsheet\rows\columns\column.jpg
The issue is that it is only happening on a select few emails being sent. The directory is hardcoded as above while the name of the signature is pulled from a table in my db.
The problem seems to be the use of relative pathing in this line
<cfset variables.signatureUrl = '../../../urls/files/messages/spreadsheet/rows/columns/' & #SignatureDetails.getDigitalSignature()#>
It is possible that the code is being run from a slightly different directory path depending on the page being executed, as such, going up 3 directories may not give you the path you are looking for. When ColdFusion cannot find a path as you have defined, it appends the know path to the end of the path in which the file being processed exists.
You can correct this by creating a mapping to the signatures (or attachments directory) directory (you define the mapping in Application.cfc) and using this to add the signature.
For mapping pointing to 'signatures' and named 'signatures'
<cfset variables.signatureUrl = '/columns/' & SignatureDetails.getDigitalSignature()>
For mapping pointing to 'attachments' and named 'attachments'
<cfset variables.signatureUrl = '/rows/columns/' & SignatureDetails.getDigitalSignature()>
If you need information about creating mappings in Application.cfc, please check this link.
Related
I am trying to add contents and an attachment from a Form to a SharePoint list. However, the Get file content using path action in my flow is failing. The error I'm receiving says "Unauthorized" and in the file content box, I receive the following message:
"status": 401,
"message": "A potentially dangerous Request.Path value was detected from the client (?).",
"source": "apidod.connectorp.svc.ms"
The file path is as follows (minus the front of the path):
sites/HSMWINGATLANTIC_Supply_Requests/Shared%20Documents/Forms/AllItems.aspx?newTargetListUrl=%2Fsites%2FHSMWINGATLANTIC%5FSupply%5FRequests%2FShared%20Documents&viewpath=%2Fsites%2FHSMWINGATLANTIC%5FSupply%5FRequests%2FShared%20Documents%2FForms%2FAllItems%2Easpx&id=%2Fsites%2FHSMWINGATLANTIC%5FSupply%5FRequests%2FShared%20Documents%2FApps%2FMicrosoft%20Forms%20Fairfax%2FVehicle%20Rental%20Request%2FSupporting%20Documents&viewid=55590b8b%2D4994%2D4e8b%2D804b%2D24f4774c21e920220815 - HSM-40 Truck Request for 15 AUG 20_Charles Power 1.pdf
c.d.power
For that Get File content using path you would need a relative path without the site url part. You can actually extract the correct path with an expression.
In the example below I retrieve the link property from the Attachment question answer value. I use a json function to turn it into an array, since Microsoft returns a string value for some reason ;)
After that I use nthindexof to determine at which forward slash (starting position of string) I need to slice with a slice function, in this case the 7th instance, which is index 6.
This should retrieve the part which we need for a get file content using path action. With a decodeUriComponent function I make sure the %20 is turned back into space characters.
Make sure you update the question id to your question id.
decodeUriComponent(slice(json(outputs('Get_response_details')?['body/re67e0cfcd95d488593347d93f2728204'])[0]['link'], nthindexof(json(outputs('Get_response_details')?['body/re67e0cfcd95d488593347d93f2728204'])[0]['link'], '/', 6)))
I found the solution to the issue. This wasn’t working because it is a group form and form responses are sent to the group’s SharePoint site; not the user’s OneDrive. Therefore, the Get file content action should be using the SharePoint connector instead of OneDrive.
I have Mule flow that is reading a file (csv) from an input directory and inserting records into a database. I'd like to know how to move this file to a 'failed' directory and send a notification email should an error occur in the flow. Currently my flow is as follows:
<flow name="mainFlow" doc:name="mainFlow" processingStrategy="synchronous">
<file:inbound-endpoint path="src/test/input" moveToDirectory="src/test/backup" responseTimeout="10000" doc:name="input-file" connector-ref="inputFile"/>
<READS FILE INTO DATABASE>
<catch-exception-strategy doc:name="Catch Exception Strategy">
<file:outbound-endpoint path="src/test/error" doc:name="error-output-file"/>
</catch-exception-strategy>
</flow>
Ideally, when the file is moved to the 'failed' directory, it has the same name as the original file with 'error' appended to beginning. I've not yet attempted the email notification as I'm unsure as to how to approach this. Any help/guidance would be greatly appreciated, thanks in advance!
The original file name is available in message properties, so you can use outputPattern="error#[header:originalFilename]" in the file outbound. If your method for reading the file content into database loses the original file content, you could set a variable to hold the content right after you have read the file, and then set the variable as payload before writing the into the error directory in the exception handler.
UPDATE: For the email part, you have several options: basically you just set your email message content as payload and then send it with Mule SMTP outbound, or some email service like Mailgun that offers a simple REST API. It is really quite simple if you just have a suitable email provider.
I have incoming email set up for SharePoint 2010, and am sending forms from InfoPath using that method, with SMTP server set up on the SharePoint Server machine. It seems easier than elevating the permissions of an anonymous user with the InfoPath code-behind option. I also tried a custom method of sending the emails but was unable to find a way to send the form data along with the email message using the InfoPath 2010 code-behind option. So, I found another way, using the advice from SharePoint UK's website.
My problem is that while removing the x-mailer header actually solved my problem regarding whole email messages, it did not allow the attached form data to be sent to the library. The message would be imported and then just disappear if I did not have the "Save original e-mail" setting enabled. Inspecting messages in the drop folder I found they had a content type of "multipart/related" and if I edited them with NotePad++ I could change that to "multipart/mixed" and the attached form data would then be imported as desired.
So I went about trying to modify the VB Script to make this happen BUT now nothing happens with the script at all. Clearly I'm doing something wrong with it and VBScript really isn't my area of expertise. Maybe it's just not possible to edit those fields or maybe I need to attack it from a different angle. How can I get my VBScript to edit the content type for these emails?
CODE:
Set shell = CreateObject("WScript.Shell")
shell.LogEvent 4, "starting mail filter"
if instr(iMsg.Fields("urn:schemas:mailheader:content-type"), "related") > 1 then
Dim logMsg = "Mail Type: " & iMsg.Fields("urn:schemas:mailheader:content-type")
Dim tempType = Replace(iMsg.Fields("urn:schemas:mailheader:content-type"), "related", "mixed")
shell.LogEvent 4, iMsg.Fields("urn:schemas:mailheader:content-type")
iMsg.Fields.Delete("urn:schemas:mailheader:content-type")
iMsg.Fields.Item("urn:schemas:mailheader:content-type") = tempType
iMsg.Fields.Update
shell.LogEvent 4, iMsg.Fields("urn:schemas:mailheader:content-type")
end if
shell.LogEvent 4, "end mail filter"
iMsg.DataSource.Save
EventStatus = 0
I looked into this in greater detail and found that the content-type property of an email message is one of the many that is read-only using this particular vbscript library. So, I would have to find some other way of editing the file, and the work involved is more than what it would take to find an alternate solution that skipped email altogether. Therefore, I am abandoning the plan of using email in this case. If you take something away from this, let it be that there are read-only properties for the mail message object in this script.
I got an error in my Magento 1.5.1 installation, that I don't know how to track down.
It says: "undefined index: url in /app/code/core/Mage/Core/Model/Email/Template/Filter.php on line 283"
I checked all email templates, but everything seems ok. Even with all email templates removed, the error still comes up.
Any hints on that?
Thanks in advance
Which means there is the url key missing in $params and $construction[2] when calling Mage_Core_Model_Email_Template_Filter::mediaDirective().
My guess would be that you got some CMS block, email template, translation .csv file, etc. using a mediaDirective which fails to assign its url value correctly.
Scan your files for
{{media url=
occurrences to see, which one fails to assign its url.
A proper one looks similiar to this:
{{media url="path/to/image.jpg"}}
I'm trying to use ColdFusion to send out emails containing attachments stored on our server.
To manage these attachments we call them 1.jpg, 2.doc ... n.ext where n is a key in a database where we hold other information about the file such as its original filename.
I can use the code:
<cfmailparam file="c:\path\1.doc">
to specify the file, but it is then attached to the email as 1.doc. Is there anyway I can override this and specify my own filename separately from the file?
You can try adding:
<cfmailparam
file="#actual_file_name#"
disposition="attachment; filename=""#changed_file_name#""">
The multiple quotes are deliberate... I they allow spaces in the file name.
Ryan's suggestion is probably the easiest solution. If you're on CF 8.01 you can make use of cfmailparam's new remove attribute. After you've renamed your attachments with cffile and passed them to cfmailparam, Coldfusion will delete them from disk for you once they have been processed by the mail spool:
<cfmailparam file="#File_path#" remove="true" />
(Before version 8.01, you had to make sure that your app didn't delete the temp files before Coldfusion's mail spool was finished with them.)
Alternatively you could call Coldfusion's underlying Java and construct your email message with attachments from memory only, with whatever names you fancy. Check out Dan Switzer's blog for an example on CF 7.02.
ColdFusion 2016 added this new attribute called filename to override the filename specified in the file attribute. A sample example is below
<cfmail from="john#sample.com" subject="filename test" to="joanna#sample.org" username="john#sample.com" password="password" server="localhost" spoolenable="false">
<cfmailparam file="c:\Book2.xlsx" filename="Offers.xlsx">
Check out the new offers sheet
</cfmail>
Now when the mail is sent to the user he/she will see this as Offers.xslx instead of Book2.xslx. More info at https://tracker.adobe.com/#/view/CF-4019518
currently the only way to do this would be to use cffile and make a copy of the file in a temporary directory, rename it and then attach that. Then you would just want to delete the file once you are finished. I don't think there is a way to attach a file but call it something different when attaching to an email.
If you are running 8.0.1 (do cfdump var="#server#" to find out) then this might make your life a little easier:
The cfmail and cfmailparam tags now have a remove attribute that tells ColdFusion to remove any attachments after successful mail delivery.
The cfmailparam tag now has a content attribute that lets you send the contents of a ColdFusion variable as an attachment. To do so, specify the variable in # signs as the content attribute value, as in the following example:
The file attribute specifies the file name to include in the mail header, not a file on the ColdFusion system
From:
http://www.adobe.com/support/documentation/en/coldfusion/801/cf801releasenotes.pdf
Since CF8 you can use file and content as per : http://www.bennadel.com/blog/1220-coldfusion-cfmailparam-s-new-content-attribute-is-awesome.htm
<cfmailparam
file="someNiceName.doc"
content="#fileRead( yourNastyFileName.doc )#"
/>