Is there a way to have swift mail place a message in the draft folder rather than just send. Trouble seems to be using the smtp instance with gmail. I've tried the imap_append like so:
$authhost="{smtp.gmail.com:993/imap/ssl}INBOX.Drafts";
$user="asdf#asdfasd.com";
$pass="asdkjasdf";
$mbox=imap_open( $authhost, $user, $pass);
//after creating the message $msg then using imap_append
imap_append($mbox,$authhost,$msg, "\\Draft");
the problem though is no matter how I modify $authhost I get a couldn't open stream. Am I missing something or is there perhaps a better alternative? Thanks
You're using the wrong folder name. The name isn't INBOX.Drafts in Gmail, it's [Gmail]/Drafts. INBOX.Drafts is what e.g. Fastmail calls the mailbox.
Related
I'm new to apple scripting and I'm trying to copy two image from a folder and paste into outlook mail body, below is the code I have written so far to compose mail and I need help in pasting two images in the mail body.
I don't want it to be an attachment file, image needs to be pasted in mail body itself.
tell application "Microsoft Outlook"
activate
set theSubject to "Subject"
set theContent to "This is my content"
set theAttachmentFile to "XXXXX"
set sendToAddress to "abc"
set msg to make new outgoing message with properties {subject:theSubject, content:theContent} -> I'm missing something here
with properties {file:theAttachmentFile}
open msg
end tell
So in case if someone is struggling with this same question. I would like to answer what I implemented.
Compose your mail body content in html format and use img tag for inserting images in your mail body.
I am trying to build a simple Suave.IO application to centralize the sending of emails. Currently the application has one endpoint that takes subject, body, recipients, attachments, and sender as form data and turns them into an EWS email message from a logging email account.
Everything works as intended in most cases, but I get a file corruption issue when one of the attachments is an excel file. In those cases, the file seems to get corrupted.
Currently, I am filtering the request.multipartFields down to only the ones that are marked as attachment files, and then doing this:
for (fileField: (string*string)) in fileFields do
let fname = (fst fileField)
let fpath = "uploadedFiles\\" + fname
File.WriteAllBytes(fpath, Encoding.ASCII.GetBytes (snd fileField)) |> ignore
The file path and the attachment names are then fed into the EWS message before sending.
Again, this seems to work with all attachments except attachments with binary. It seems like Suave.IO automatically encodes all multiPartFields as (string*string), which may require special handling when it's binary data.
How should I handle upload of binary files?
Thanks all in advance.
It looks like the issue was one of encoding. I was testing using python's request interface, and by default the files are encoded as multipart/form-data. By specifying a specific encoding for each file, I was able to help the server identify the incoming data as a file.
instead of
requests.post(url, data=data, files={filename: open(filepath, 'rb')})
I needed to make it
requests.post(url, data=data, files={filename: (filename, open(filepath, 'rb'), mimetypes.guess(filepath)})
With the second python script, files do end up in the files section of the request and I was able to save the excel file without corruption.
I'm getting this LookupError when I try to use Get Links From Email keyword:
Open Mailbox server=imap.googlemail.com user=user#mail.com password=pass ${proWelcomeMail} = Wait for Email recipient=${USER_EMAIL} subject=Welcome
Open Link From Email ${proWelcomeMail}
...
Close Mailbox
Output:
ImapLibrary . Get Links From Email ${proWelcomeMail}
LookupError: 'quoted-printable' is not a text encoding; use codecs.decode() to handle arbitrary codecs
Is there a workaround for this please?
You can change the library's code by yourself because it's not fixed by the maintainer. Change the line 135 in file init.py "decode('quoted-printable')" to "decode('utf-8')".
Use the fork ImapLibrary2 which has fixed it already
https://pypi.org/project/robotframework-imaplibrary2/
I have a script that's a plugin for redmine which enhances the application to send encrypted mail using gpg. At some point this stopped working. Unfortunately the one who wrote that script is not available anymore and I am an admin with only very limited knowledge of RoR.
The problem is, that obviously the script creates a file with the mail body, saves it to temp, encrypts it to an output file, reads this output and then sends the mail.
With an empty /tmp directory (such as after rebooting the whole server), the gpg.in file gets created when I try to send a test mail. But then I get an error that the gpg.out file was not available. Creating it using touch does cause an empty email being send so obviously the script does not write anything to that file.
File.open('/tmp/gpg.in', 'w') do |f1| #<--- Works, file is created
f1.puts(body)
end
list_of_keys = [ rec ]
Gpgr::Encrypt.file('/tmp/gpg.in', :to => '/tmp/gpg.out').encrypt_using(list_of_keys) #<- gpg.out wird nicht erzeugt.
text = ""
File.open('/tmp/gpg.out', 'r') do |f2| #<- throws file not found error, if file not there. When file was created empty using touch, it sends an empty mail
With my limited RoR knowledge, I can't figure out how to debug this. Permissions on /tmp are 777 so the script should be allowed to write there and obviously has because File.open('/tmp/gpg.in', 'w') works correctly all the time without an error. Hence I expect the problem in Gpgr::Encrypt.file not working correctly, but I also don't get any error from that function it fails silently.
Currently we need fetch mails from an IMAP server using Mule ESB. Once the mails have been fetched, we only need the attachments and save them on the harddrive. So far so good. Now I got a couple of questions:
How do I keep the original name intact using a file:outbound-endpoint?
How can I check how many attachments I got?
How do save a copy of the mail on the IMAP and local drive?
#1: I tried #header:fileName or #originalFileName or even removing the outputpattern (this results in the filename being "35c7dea0-519a-11e1-b8b2-092b658ae008.dat")
#2: I am trying to make a flow where I check how many attachments there are. If there are less then 1 then I want to save the files and no further process them. If it's more then 1, then save it and process it. I tried COUNT but it didn't work.
#3: am trying to MOVE a message when READ to a back-up folder on the IMAP-server. On top of that I'll save a copy on the local server. Problem is that with the current code, the message does not get marked as read nor moved. The messages stay unread and they get copied (over and over, enldess loop) instead of getting moved to the IMAP back-up folder. When enabling the deleteReadMessages then the loop is broken but the message does not get copied on the IMAP.
Here's the code I am currently using:
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:spring="http://www.springframework.org/schema/beans"
xmlns:imap="http://www.mulesoft.org/schema/mule/imap"
xmlns:file="http://www.mulesoft.org/schema/mule/file"
xmlns:email="http://www.mulesoft.org/schema/mule/email"
xmlns:vm="http://www.mulesoft.org/schema/mule/vm"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/3.2/mule.xsd
http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/3.2/mule-file.xsd
http://www.mulesoft.org/schema/mule/imap http://www.mulesoft.org/schema/mule/imap/3.2/mule-imap.xsd
http://www.mulesoft.org/schema/mule/email http://www.mulesoft.org/schema/mule/email/3.2/mule-email.xsd
http://www.mulesoft.org/schema/mule/vm http://www.mulesoft.org/schema/mule/vm/3.2/mule-vm.xsd">
<imap:connector name="imapConnector" checkFrequency="5000"
backupEnabled="true" backupFolder="/home/mark/workspace/Eclipse/RHZ_Project/src/Archive/"
mailboxFolder="INBOX" moveToFolder="INBOX.Backup" deleteReadMessages="false"
defaultProcessMessageAction="SEEN" />
<expression-transformer name="returnAttachments">
<return-argument evaluator="attachments-list" expression="*.txt,*.ozb,*.xml" optional="false"/>
</expression-transformer>
<flow name="Flow1_IMAP_fetch">
<imap:inbound-endpoint user="USER" password="PASS" host="IP"
port="143" transformer-refs="returnAttachments" disableTransportTransformer="true"/>
<collection-splitter/>
<file:outbound-endpoint path="/home/mark/workspace/Eclipse/RHZ_Project/src/Inbox/#[function:datestamp].dat">
<expression-transformer>
<return-argument expression="payload.inputStream" evaluator="groovy" />
</expression-transformer>
</file:outbound-endpoint>
</flow>
</mule>
1) How do I keep the original name intact using a file:outbound-endpoint?
Attachments are javax.activation.DataHandler instances so you should be able to call getName() on them, with an OGNL or Groovy expression. For example:
#[groovy:payload.name]
Should give you the original attachment name.
2) How can I check how many attachments I got?
Before the splitter, use a choice router and an condition that checks the size() attribute of the attachment list, like:
#[groovy:payload.size()>1]
3) How do save a copy of the mail on the IMAP and local drive?
I do not know what the issue is here. Maybe marking as seen is not supported. Or maybe the fact that you disable the transport transformer prevents a post-read action to kick in.
By the way, I suggest you leave the default transport transformer as-is and move the returnAttachments transformer after the inbound endpoint, before the splitter.