With the help of javax.mail.internet.MimeMessage etc. to create the EML file
Hello
I have e-mail messages stored in a MySQL database and their attachments stored in base64 encoded text. I try to perform a loop over a query and write properly formatted. EML file for each message. I started from the borrowed code that was used to send messages IMAP, and I had no experience with Java, but I have since worked through some tutorials and I now know how to write and compile a simple class. But I always hurt (a lot!) to instantiate the correct Java objects in common sense and order in ColdFusion.
Here is what kind of work, with problems, that I will detail below:
< cfscript >
clsSession = createObject ("Java", "javax.mail.Session");
objProperties = createObject ("Java", "java.util.Properties");
MSG = CreateObject ("Java", "javax.mail.internet.MimeMessage");
MMP = CreateObject ("Java", "javax.mail.internet.MimeMultipart");
MBP = CreateObject ("Java", "javax.mail.internet.MimeBodyPart");
objRecipientType = CreateObject ("Java", "javax.mail.Message$ RecipientType");
SDS = CreateObject ("Java", "javax.activation.FileDataSource");
FSO = CreateObject ("Java", "java.io.FileOutputStream");
OOS = CreateObject ("Java", "java.io.ObjectOutputStream");
< / cfscript >
< cfloop query = "getAllMessages" >
<!-here I also do a 'qGetMsgAtts' query to get all attachments by getAllMessages.msg_id,
and valueList (qGetMsgAtts.attIndex) to use to create a "msgAttachmentsList"-->
<! - initialize a MimeMessage object java - >
< cfscript >
objProperties.init ();
(I was actually setting properties here, but never got their and code works without them)
objSession = clssession.getInstance (objProperties);
Message
Msg.init (objSession);
msg.addFrom (add.parse (getAllMessages.msgFrom, false));
msg.setReplyTo (add.parse (getAllMessages.msgFrom, false));
msg.addRecipients (objRecipientType.TO, add.parse (getAllMessages.msgTo, false));
Etc... no problem by setting the msg properties
Increment = increment + 1;
file name
thisFileName = "#userId #_ #myFun.doCountToken (increment) # .eml"; my function doCountToken (integer) pads simply with zeroes.
Parts of body of message
MBP.init ();
If (not msgIsHTML)
{
mbp.setText ("msgBody");
}
on the other
{
mbp.setContent (msgBody, "text/html");
}
mmp.addBodyPart (mbp);
msg.setContent (mmp);
If (len (msgAttachmentsList)) / / message has attachments
try / / TRY TO ATTACH FILES
{
{/ / qGetMsgAtts.colnames: msg_id(2), attIndex, fileName, fileMIMEType, fileMacCreator, fileMacType, fileContents}
writeOutput (' spare part & msgAttachmentsList & "< br / > '");
for (i = 1; i is listLen (msgAttachmentsList); i ++)
{
FDS.init (qGetMsgAtts.filecontents); WORK
MBP.init ();
mbp.setDataHandler (dh.init (SDS)); WORK
mbp.setFileName (qGetMsgAtts.fileName [i]); WORK
mbp.setContent (qGetMsgAtts.fileContents [i], qGetMsgAtts.fileMIMEType [i]); WORK
mmp.addBodyPart (mbp);
}
msg.setContent (mmp);
}
}
{} catch (everything except)
writeOutput ("#excpt. # Error type attach content. #excpt. Message # #excpt. ("Retail # < br >");
}
aFile = thisFilePath & thisFileName; PATH AND NAME
FOS.init (afile); //
OOS.init (FOS); //
try / / WRITE THE FILE TO DISK
{
msg.writeTo (oos); ONLY WORKS IF MIME TYPE IS text/plain or text/html
OOS. Flush();
OOS. Close();
FOS. Close();
}
{} catch (everything except)
writeOutput ("#excpt. # Error type attach content. #excpt. Message # #excpt. ("Retail # < br >");
OOS. Flush();
OOS. Close();
}
< / cfscript >
< / cfloop >
But who wrote the correct number of files with the correct file names, there are 2 major problems at this stage:
- the content of the file on the disk seems to contain all messages. I do not understand why, I do msg.init () at the top of each loop. (The limit of the part also seems to be the same in all parts in each message.)
- I get an error like the following for any MIME type as text/plain or text/html:
javax.activation.UnsupportedDataTypeException error to fix the content. No object DCH MIME type application/pdf no object MPC for the mimetype application/pdf
I Googled it and I understand that I probably need to use something like
bads = createObject ("java", "javax.mail.util.ByteArrayDataSource");
Baos = createObject ("Java", "java.io.ByteArrayOutputStream");
.. .somewhere in the mix, but all my attempts to instantiate objects have so far failed, usually with the "method not found" or "constructor not found."
I hope that the explanation is logical. Someone at - it never to write using ColdFusion EML files? I will be eternally grateful for suggestions or extracts.
Richard
York U CA
EDUYork wrote:
The following code appears to do what I wanted, except that when I opened an EML message exit 1) it is a corruption at the beginning of the headers and at the end of the body, and 2) the attachments does not actually open...
...
myFileOutputStream = fos.init (emlFile); //
myObjectOutputStream = oos.init (myFileOutputStream); //
Hi Richard,
It seems OK except for the part that writes to a file. You only need a stream of output here, so just using FileOutputStream. I think ObjectOutputStream is most used for serialization and is probably what is causing the strange result here.
VR;
{
emlFile = emlFilePath & thisFileName;
outStream is CreateObject ("Java", "java.io.FileOutputStream") .init (emlFile);.
newMessage.writeTo (outStream);
outStream.flush ();
outStream.close ();
}
catch (everything except)
{
writeOutput ("#excpt. # Error type attach content. #excpt. Message # #excpt. Detail #.
");
only close the stream if it exists
If (IsDefined ("outStream"))
{
outStream.close ();
}
}
BTW, Sun is the best reference for javax.email: http://java.sun.com/developer/onlineTraining/JavaMail/index.html . So, have you ever found if there is an easier way to do it? I wonder if you can store the entire message (header, etc.) without attachments?
Tags: ColdFusion
Similar Questions
-
On my office workstation (Windows Server 2008 R2), I use Outlook 2010 to network and business-related emails. I installed Live Mail 2011 for my personal mail (hotmail, gmail, yahoo, etc) in order to keep it separate and open it only once or twice a day. I said to Live Mail was not the client by default, but all 60 seconds or so he tries to assign the .eml file type to itself in any case (even if it is not running). I've got WinPatrol keeping my setup, but I don't want to say no to him, "do not allow this change" once per minute. How can I send live to accept his secondary position and stop trying to run away with the .eml file type?
original title: let my Filetype Alone!There is no default program to manage the eml file type in Server 2008 R2, and is not one that is recognized by Outlook. I would suggest you go ahead and set the eml file type opened by WLM under control panel | Default programs. Then you can leave it alone, I hope. If not, then ask in the forum here WLM: www.windowslivehelp.com
Steve
-
Need help to open two images with the same file with different exposures on the screen at the same time in the Photoshop creative cloud (in previous versions we could open two images of the same nef (raw) file and then combine them on the screen with the move tool. They have become a composite of two layers which could be developed further with the mask tool.
Hello
Please go to the preferences > workspace and uncheck the option 'open the document in the tabs '.
Now you can click on file and choose file > open and open the two images in two different windows which can be arranged side by side.
Thank you
-
My Cookie file was corrupted in data and my programs continually pop up with the 'corrupt file' error when a program opens, pointing to \Users\name\Appdata\Roaming\Microsoft\Windows\Cookies.
The problem is, Chkdsk will not fix this, and I can't access the file. This opens up a world of problems when I need to fix this error, so I can upgrade to Windows 7. Help, please!
I just ran the scan again. He said of the errors found, but could not be repaired.
This problem actually has nothing to do with internet explorer. It's the cookies folder that is corrupt in the Windows folder in roaming. The error file is in conjunction with the programs, that I try to run (AIM, Skype, so forth). Trying to enter the folder it says it's corrupt. I don't know what is the root of the problems or how to solve this problem, but these measures have not helped so far. Regarding the repair, I will try that next.
http://Tinypic.com/view.php?pic=14mw4ly&s=4
Here is a picture. This is the error of the lower right
It's what the tool SFC to see system files corrupted and try to repair the system files.
SFC could not fix it.Looks like you will need to do this:
http://www.Vistax64.com/tutorials/88236-repair-install-Vista.html
Read the info on the link above.
Good luck with it.
Let us know how you go with it.
See you soon.
Mick Murphy - Microsoft partner
-
How to open files with the .eml extension in Windows 7 Professional
How to open e-mails that have been saved in the .eml format in Windows 7? I can record e-mails on my server that works under XP and when I click to open the saved email it opens the e-mail. When I try to open them from the workstation that is running windows 7, it doesn't do anything but open my email program no real email. It worked for awhile, but now it doesn't. I tried to change the "open with" and choose Windows Live Mail (my e-mail program on the two compters) but same thing opens just the real Windows Live Mail not e-mail. Help, please
I found the solution: Set Window Live Mail (WLM) defaults for EML files in Winodws 7:
Control Panal, programs. Set your Defailts to choose default programs, Windows Live Mail, for this program. Make sure the EML files is checked.
It's another forum by Mike - http://TechHelp.Santovec.us
-
Original title: Windows Mail (tile)
Hello everyone.
I had a few problems with some of my tiles (Mail, games, music, etc.) so I have WSReset.exe and since then I could not find one of these tiles. I searched the Store and tried to re - install, but it says that I must admit. I don't know what to do. Please help me...
Thank you...Hi rap.
Thanks for the reply with the status of the issue.
Here in this scenario, you need to refresh your computer after the backup of your data. Refresh your PC reinstall Windows and keep your personal files and settings. It also keeps the applications provided with your PC and applications that you have installed in the Windows store.
How to refresh, reset or restore your PC:
http://Windows.Microsoft.com/en-us/Windows-8/restore-refresh-reset-PC
Note: refer to the section "refresh your PC without affecting your files.
Warning: Apps that you have installed Web sites and DVD is deleted. The applications provided with your PC and applications that you have installed in the Windows store will be resettled. Windows puts a list of apps removed on your desktop after you refresh your PC.
If you do not have installation media, you can see the following article from Microsoft Help to create installation media.
http://Windows.Microsoft.com/en-us/Windows-8/create-reset-refresh-media
Note: The steps also apply to Windows 8.
Please reply with the status of the issue, so that we can confirm that the issue is resolved.
-
Problem with the executable files
Hello all, I need a help from you...
I use LV 2009 SP1 Professional Development Suite on Windows Seven and I have a problem with the executable files, a problem that I have ever found with other versions of LV (8.x, for example) and I'm a little surprised...
In the attachment you will find an example of what I mean.
There are two base screws, the main one (prova) and a Subvi (provasubvi). The main vi launches the Subvi and the Subvi simply create a chart. As you can see on the screws works fine, without any kind of problem.
I also created the exe file, without specifying that no particular option... and 'magic' of the application does not work as I want. In particular, it seems that the Subvi is running, but the front panel will not be accessible.
I also try to play with the Subvi construction structure and options, but nothing change.
Did you ever solve something like that?... I would say that I thank you in advance for any suggestion...
Andrea
Hello andrea,.
Looking at your project I've heard that you do not include the Subvi during the build of the project. SO I slightly modified. Please find the attachments.
Thank you and best regards,
srikrishnaNF
-
Does anyone know how to open an old MS Word document file with the .ltr file extension?
original title: file extension
Does anyone know how to open an old MS Word document file with the .ltr file extension? I would appreciate your help. Thank you.
If it's a Word document, why not just use Word to open it?
-
I lost my CD windows 7 Home Basic, can you provide me with the ISO file
I'm on PC assembled with i3 1st gen 3.07 GHZ processor Intel with 4 GB of RAM.
I put in Windows 7 Home Basic and have the activation key for the same thing but lost my CD. Can you provide me with the ISO files approved for her.
I had tried a lot of ISO file, but none worked mainly for basic Stater of Windows and home proplary. Is the ISO file or my PC is not supported with Home basic.
If Yes, then what is the solution.
Some of the links that I tried are
https://***.to/Windows-7-all-in-one-pre-activated-excellent-t7661549.html
Please help as soon as possible.
For 5 years, Microsoft made it fairly easy for users of the Windows 7 operating system to get reinstall media. If you have lost your support disc or installation retail collection; either it has been damaged or defective; You can download a copy of the edition that you have licensed from a membership site called Digital River. More recently, Microsoft ended the availability to reinstall media that you can download as a. File ISO in Digital River, which is a digital reproduction of an optical disc.
It was particularly convenient for people who could not easily get the manufacturer's recovery media, did not want to pay the fees required to get or preferred a clean configuration without the software packaged manufacturers or even a recovery partition does not work. It's easy to use, all you had to do was reinstall and reactivate using the product key located on the certificate of authenticity and download all the drivers on the manufacturers website.
Given that this option is no longer available, what are your options? See the article for more details:
-
I had CS5 on a computer that has crashed with WIndows 7. How to restore my CS5 with the backup files?
Available downloadable Setup files:
- Suites and programs: CC 2015 | CC 2014 | CC | CS6 | CS5.5 | CS5 | CS4, CS4 Web Standard | CS3
- Acrobat: DC, XI, X | Suite X | 9,8 | 9 standard | 8 standard
- Captivate: 9 | 8 | 7 | 6 | 5.5, 5 | 1
- Cold Fusion: 11: 10 | 9.0.2 version 9.0.0, 9.0.1, 8.0.1, 8.0.0, 7.0, 6.1, 6.0, 5.0, 4.0
- Contribute: CS5 | CS4, CS3 | 3,2
- FrameMaker: 12, 11, 10, 9, 8, 7.2
- Lightroom: 6.4| 6| 5.7.1| 5 | 4 | 3
- Photoshop Elements: 14,13,12,11,10 | 9,8,7 win | 8 mac | 7 mac
- Premiere Elements: 14,13,12,11,10| 9, 8, 7 win | 8 mac | 7 mac
Download and installation help links Adobe
Help download and installation to Prodesigntools links can be found on the most linked pages. They are essential; especially steps 1, 2 and 3. If you click on a link that does not have these listed steps, open a second window by using the link to Lightroom 3 to see these "important Instructions".
-
Re-import L/r &; battery with the original file?
Re-L/r & battery with the original file import
Hi, need some help please.
After have exported them to an external editor for re - I want to import the image in lightroom, when I click on this option, prior to export (in re - import), it merely to send the image to the original folder not in the preview pane the long side of the Photo original/s and L/R so if I want to work on this, once again , I open the L/R folder and drag it into an external editor.
I've been under DISPLAY/SORT but don't no if any option to choose here.
Hope you understand the question
Thank you
RussSorted
If image does not appear in Lightroom, check that the Source film indicator and the menu does not appear "previous import." If you have switched to "Previous import", access the menu, and then select all photographs.
-
My links do not work when I combine another file with the pdf file
My favorite internal links do not work when I combine another file with the pdf file.
External links continue to work properly, though.
It makes no sense to me at all... but I hope that one of you kind folk can help?
With the tool link in Adobe Acrobat, you can edit the links or create new links.
-
Distribute an image with the AIR file
Hello-
Is there anyway that I can broadcast an image with the .air file (without incorporating the image in the .swf)?
Thank you for your help.Hello-
Is there anyway that I can broadcast an image with the .air file (without incorporating the image in the .swf)?
Thank you for your help.
-
problem with the Finder - files and folders displaying incorrectly
After acquiring a new iMac, I noticed a problem with the Finder - files and folders are displayed wrong (see table).
This is what happens always after the files have been transferred from one folder to another. I was reminded of my days of using Mac OS in the 1980s when automatic setting of files was not so "automatic." I use Mac OS for decades and I don't remember the last time I had to think about GUI problems like that.
Other problems in the graphical display of files and folders were introduced, such as when you have hundreds of files in a single folder, you end up deleting about 30 to 40 of them say in a particular section, and you end up with gaps of the ChartSpace where files used to be, that is the remaining files automatically rearrange themselves (fill in these gaps) - never. A week later, you open the folder, and the gap of GUI is still there.
I decided to do a clean install of the operating system but nothing works.
Is there some setting in Prefs I'm missing?
Hi there highland99,
Looks like your folder icons are not accommodating themselves automatically you plan to do. To me, this indicates that you have organize by the None value in the view menu. You can change the way files and folders are prepared automatically by clicking on view > reorganize by and selecting how you would like that fixed.
Thank you for using communities of Apple Support.
-
Which programs are associated with the xcm files
I found a folder in my folder system program (. 86) that I don't know or I don't know where it comes from. It has a bunch of XCM file in the known folder that cannot open my own computer, can not give me info on how to open and cannot tell me which of my programs, he joined. I want to delete it because it seems that a suspect case, but not because I can not check programs what or how much it may or may not be associated with.
Sincerely yours, Aaron Baker.Take a look at this link:
http://pcsupport.about.com/od/FileExtensions/f/xcmfile.htm
Excerpts .....................................
What is the .xcm file?
Response: A file with the XCM file extension is a Concept exported CmapTools mapping file.
How to open a XCM file:
The easiest way to open a file XCM is double-click on it and let your PC decide which default application should open the file. If no program opens the XCM file then you have probably an installed application that can view and/or edit files XCM.
Maybe you are looking for
-
Satellite L350 - no sound after uninstalling some programs
Hello I just bought a Satellite L350 and I started uninstalling some programs.Since then, I have more no sond.I guess I uninstalled too much and I would like to know the program I have to reinstall and where I can find it. Thanks fo your answers!
-
Are the substantive case on every 17.3 "g7 2000 laptops series interchangeable? I have a dx 2275 and need low case.
-
Access ccp cannot express through browser
Hello I just had installed 3 new routers, 2911 and two of 1941. Two of the three routers I can access ccpexpress through my browser. It is one of the 1941 that I can't, no connection, nothing but "cannot display the Page. I can't telnet in all three
-
SpeedGrade grayed out button to make
I'm trying to make in Adobe SpeedGade and I can't. I'll tab render and do everything that the tutorials tell me to do. However, the Render button never lights (white letters Tower) but there is grey and unclickable. I just updated the Adobe software
-
Storage VMotion is related to my correct Vsphere license?
I just want to confirm, that features such as vmotion, ha and dr are related to my VSphere ESXi company correct license, not Vcenter right?