attaching file after opening default email client(Qt 4.4,Linux)
Hi,
need help in implementing this--
When I click 'email photo', the default email client should open up and the photo currently displayed in the gallery is automatically attached.
I have got the default email client to open (but,can't attach the photo) by using this--
now if i give the path of the picture--
the pic gets attached.But,I don't want that (cause I will keep opening different picture files in the application so, filenames will keep changing).
When I view/open any picture ,I get it's path in a variable 'fileName' - -
Code:
fileName
= QFileDialog::getOpenFileName(this,tr
("Open File"),
QDir::currentPath());
but, if i write --
it doesn't work and shows "cannot attach 'fileName':no such file or directory."
But,if you use a QMessageBox inside the email() slot to print 'fileName', you get the correct filepath.
Can anyone suggest on what to change in the code to get the correct file attached?
Thanks in advance.
Re: attaching file after opening default email client(Qt 4.4,Linux)
have you tested something like this ?
Re: attaching file after opening default email client(Qt 4.4,Linux)
Hi,
thanks a lot,your suggestion worked.
Re: attaching file after opening default email client(Qt 4.4,Linux)
Dear all,
I have got the default email client to open (but, can't attach the file in windows) by using this.
QString l_string = QFileDialog::getOpenFileName(this,tr("Open File"), QDir::currentPath());
QDesktopServices::openUrl(QUrl("mailto:test@test.c om?subject=test&body="+l_string+"&attach=" + l_string));
Thanks in advance.
Re: attaching file after opening default email client(Qt 4.4,Linux)
yes, it is not working on windows for me too.
Any suggestions?
Re: attaching file after opening default email client(Qt 4.4,Linux)
Have you checked that l_string contains no spaces ? Not tested, but you could try this :
Code:
QDesktopServices:openUrl
(QUrl("mailto:test@test.com?subject=test&body="+l_string
+"&attach=\"" + l_string
+ "\""));
Re: attaching file after opening default email client(Qt 4.4,Linux)
Thanks for the suggestion.
But i am not ablw to attach a file even if i give the name of file.(VS2010)
Like this:
QDesktopServices::openUrl(QUrl("mailto:test@test.c om?subject=test&body=hi&attach=agent_reporting.sln " ));
New mail is opened with subject and all but the file is not attached?
Please suggest why this is happening and what to do to attach the file?
Thanks
avinash
Re: attaching file after opening default email client(Qt 4.4,Linux)
On the Linux machine it was working by accident and not design.
The file is not attached because the mailto URL scheme does not specify "attach" as a special header like "body". You may specify any header defined in RFC 822, which includes the only other header guaranteed to be supported... "subject". You could try building a mime encoded multi-part body and encoding that into the "body" along with Content-Type and MIME-Version headers. No guarantees though, because the headers are not guaranteed, and URLs generally have an implementation-defined upper limit on their size that is too small for a decent attachment.
Some Windows mail clients accept a non-standard "attachment" header.
Re: attaching file after opening default email client(Qt 4.4,Linux)
So does anybody succeeded in attaching file to the mail in Windows?
Can I have sample code that is working in Windows for file attachment. As I am facing the same problem in Windows.
Thanks in advance.
Re: attaching file after opening default email client(Qt 4.4,Linux)
As explained above, you cannot reliably use mailto: links. You can try any of the Windows-specific methods;
- Simple Mapi (does not support HTML tags in the body)
- Extended Mapi (Does support HTML tags)
- CMC (Common Messaging Calls) Is a non-platform specific. When it is used on Windows it will access the MAPI properties.
- MAPI Activex
- CDO (Collaboration Data Objects).
- Automating Outlook
- and probably others
I would guess that CDO is worth the most investigation.