Re: Message body becoming NULL
- From: Shyam Shrivastav <shyam shrivastav azingo com>
- To: Sergio Villar Senin <svillar igalia com>
- Cc: tinymail-devel-list <tinymail-devel-list gnome org>
- Subject: Re: Message body becoming NULL
- Date: Thu, 30 Apr 2009 21:36:24 +0530
Dear Sergio
I am doing exactly as written in the doc and as tmut is doing. Here
again including the code
Many thanks for your help
------------------------------------------------------------------
email_core_create_tny_email_msg (TnyPlatformFactory * platfact, gchar
*msg_body, gchar *subj, gchar *from, gchar *to,gchar *cc,gchar *bcc)
{
TnyMsg *msg = tny_platform_factory_new_msg (platfact);
TnyHeader *header = tny_msg_get_header (msg);
TnyStream *plain_stream = tny_camel_mem_stream_new ();
tny_header_set_subject (header, subj);
tny_header_set_from (header, from);
tny_header_set_to (header, to);
if ( g_strcmp0 (cc,NULL) != 0)
{
tny_header_set_cc (header, cc);
}
if ( g_strcmp0 (bcc,NULL) != 0)
{
tny_header_set_bcc (header, bcc);
}
tny_stream_write (plain_stream, msg_body, strlen (msg_body));
tny_stream_reset (plain_stream);
tny_mime_part_construct (TNY_MIME_PART (msg), plain_stream, "text/plain", "7bit");
g_object_unref (G_OBJECT (plain_stream));
g_object_unref (G_OBJECT(header));
/* Adding attachments where mime_part_list is list of attachments */
iter = tny_list_create_iterator (mime_part_list);
while (!tny_iterator_is_done (iter))
{
TnyMimePart *part = TNY_MIME_PART (tny_iterator_get_current (iter));
tny_mime_part_add_part (TNY_MIME_PART (msg),part);
g_object_unref (part);
tny_iterator_next (iter);
}
if (iter)
g_object_unref (G_OBJECT (iter));
return msg;
}
----------------------------------------------------------
Thanks
Shyam
On Thu, 2009-04-30 at 17:35 +0200, Sergio Villar Senin wrote:
> Shyam Shrivastav escribiu:
> > msg_body is OK but the body of the email message(msg) which gets
> > prepared becomes NULL, it only contains attachment. Also if there are no
> > attachments to add to the body that is tny_mime_part_add_part is not
> > used at all then the body is fine, I am looking at the code and looks
> > like problem somewhere in tny_mime_part_add_part.
> > Also the workaround is to prepare the body also as a mime part and add
> > to the actual message(steps shown under) but in this case the email
> > message is always shown to have an attachment even though there is no
> > attachment
>
> Shyam you can find information about how to create emails in the project
> trac, here it is some documentation:
> http://tinymail.org/trac/tinymail/wiki/CreatingAMessage
>
> Now, taking a look at your problemm how do you create the TnyMsg
> instance? Note that you have to set the proper content type of that
> TnyMimePart, something like
>
> tny_mime_part_set_content_type (TNY_MIME_PART (msg), "multipart/mixed");
>
> Could you paste the code used to create the message?
>
> Br
[
Date Prev][Date Next] [
Thread Prev][Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]