Swift 4, CorePlot, send chart via mail app (with MessageUI) - swift

Can I somehow take the chart (which was made with CorePlot) from view and send it as a file to another person via mail app? I want to send mail with the help of MessageUI. I feel fine if just the picture will be sent.

Use the -imageOfLayer method to get a PNG of the graph or the -dataForPDFRepresentationOfLayer method to get a PDF and attach the resulting file to a message.

Related

Delphi - Using resource in Email rather than image

In Delphi, I create emails in HTML using the following code to display a signature in the message:
cMsg:= cMsg + ' <img src="BarrysSignature.jpg" '>
Which means I need to have the .jpg available in the current directory (and distribute it with the executable).
I also use these same signature .jpg files elsewhere in my program, but I've loaded them as resources. What would be better in the emails is if I used the resource for the signature in the email, rather than the external .jpg picture.
I've tried a few ways of doing this but can't get it working. Any thoughts, please?
Similar to #Dmitry's answer, in Indy you would also need to attach the image data to an email (the TIdMessage component), assign the attachment's Content-ID header (the TIdMessagePart.ContentID property), and then refer to that ID in the HTML using a cid: URL where needed.
Refer to these blog articles on Indy's website for how to do this:
HTML Messages
New HTML Message Builder class
I do want to mention one thing, though. Where the articles talk about using TIdAttachmentFile for attachments, you actually don't need to save your image resource to a temporary file at all in this situation. You can alternatively derive your own class from TIdAttachment (let's call it TIdAttachmentResource), and have it override the virtual OpenLoadStream() and CloseLoadStream() methods to return/free a TResourceStream to your resource data, respectively (see the source codes for TIdAttachmentFile and TIdAttachmentMemory for examples). Then you can simply add TIdAttachmentResource objects to the TIdMessage.MessageParts collection as needed, and Indy will be able to encode the email using the image resource directly, no file needed.
In Outlook, you will need to extract the resource to a temporary file, add the image as an attachment, set its PR_ATTACH_CONTENT_ID MAPI property, delete the file. Your HTML body would need to reference the image by its content-id, e.g. <img src="cid:xyz">, where "xyz" is the value of the PR_ATTACH_CONTENT_ID property.
See Including Pictures in an Outlook Email

load magento email template

I'm using my own code to send out SMS's to the customers at the same time as the emails go out. I do this by getting the email template code with
$code = $this->getTemplateCode();
and then trying to load the corresponding SMS template with
$sms = $this->loadByCode('sms_'.$code)->getTemplateText();
I then check if $sms is empty before proceeding to send the text, meaning that I can add or remove connected SMS templates at will. The problem I'm having is that I sometimes, when there is no connected "sms_*" template, I get the full email sent out as the SMS instead of no text being sent.
I've debugged the code by sending out the template it tries to load as the actual SMS, and received "sms_creditmemo", but when I instead load it with the method above and do a var_dump($sms); exit;it shows me that it loaded the template "creditmemo_invoice" which is the email template I use instead of "creditmemo" when the payment method is detected. I make sure to use the original template string in $code (used to load SMS template) no matter the payment method.
Now my question would be how this can even be possible, does the loadByCode take best matching template or is there some other more serious bug I've missed, maybe there's better ways to load in the templates and make correct checks to see if they even exist?
I solved this by checking if the correct email template gets loaded with
if ($this->loadByCode($template)->getTemplateCode() == $template)

Send info regarding user via XMPP in iOS

I have implemented the chat and everything is working good. I follow that link http://mobile.tutsplus.com/tutorials/iphone/building-a-jabber-client-for-ios-server-setup/ tutorial to implement chat app. Now i want to send info regarding user like photo,birthday,nickname etc. So i just want to create that info and send to other user.
I also want to send image(Data) to another user.
To set an avatar and other user-information you should have a look at the vcard extension XEP-0153 (specification and implementation).
You will find an example implementation for the vCard within the XMPPFramework iphone demo.
You would use the following calls to update and fetch vCards:
- (XMPPvCardTemp *)fetchvCardTempForJID:(XMPPJID *)jid;
- (XMPPvCardTemp *)fetchvCardTempForJID:(XMPPJID *)jid useCache:(BOOL)useCache;
- (void)updateMyvCardTemp:(XMPPvCardTemp *)vCardTemp;
To send binary data, you have some options. The XMPPFramework implements XEP-0065. There are other methods to send data like:
XEP-0066: Out of Band Data
XEP-0096: SI File Transfer
XEP-0234: Jingle File Transfer
Which you could probably implement as extensions and integrate them into the XMPPFramework.
In will integrate sending binary data like images and videos myself soon. So please leave a comment about your implementation.
first setup user profire in spark and then use [XMPPvCardTempModule myvCardTemp]

Nagios does not send the graph in email

So, I have been trying to make Nagios work with Graphite to send alert emails but that's not working right. I used the following URL to set everything up:
http://www.protocolostomy.com/2012/02/24/sending-alerts-with-graphite-graphs-from-nagios/
The sendgraph.py alone, with the correct parameters sends a correct email with the graph properly displayed. But if I use nagios to send the graph it sends the correct message but the graph does not show up. I only get a file name which when tried to open gives me this message: "It may be damaged or use a file format that Preview doesn’t recognize." I have no idea why. All the work of sending the graph is done by sendgraph.py and it has all the correct parameters to it for sure because the URL gives the correct values from Graphite and then I get the email (so the email is correct) and I get the description and state of the graph correctly.
Could anyone please suggest me a way out of this?
Thanks!
In the Nagios documentation for macros it states:
"Additionally, any macros that contain custom variables are stripped for safety and security."
In you nagios.cfg file, try removing the '&' from this line:
illegal_macro_output_chars=`~$^&"|'<>

How to get the no of attachments in an email using objective-c?

Hi am new to xcode programing,i am trying an app regarding the email attachments to show the no of attachments an email contains,i got the single attachment showing but i need how n=many are there in particular email,if any body knows about this please help me.Here is the code regarding the app:
From looking solely at the code you have provided, it would appear that all you need is [attachments count] to provide the number of attachments in the current message