/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ #include #include "camel-mime-message.h" #include "camel-multipart.h" #include "camel-stream.h" #include "camel-stream-fs.h" #include "camel-data-wrapper.h" #include "camel.h" int main (int argc, char**argv) { CamelMimeMessage *message; CamelMultipart *multipart; CamelMimePart *body_part; CamelMimePart *attachment_part; CamelStream *attachment_stream; CamelStream *stream; CamelException *ex = camel_exception_new (); gtk_init (&argc, &argv); camel_init (); if (argc < 2) { attachment_stream = NULL; } else { if (argc == 2) { attachment_stream = camel_stream_fs_new_with_name (argv[1], O_RDONLY, 0, ex); if (attachment_stream == NULL) { fprintf (stderr, "Cannot open `%s': %s\n", argv[1], camel_exception_get_description (ex)); return 1; } } else { fprintf (stderr, "Usage: %s []\n", argv[0]); return 1; } } message = camel_mime_message_new (); camel_mime_part_set_description (CAMEL_MIME_PART (message), "a test"); camel_medium_add_header (CAMEL_MEDIUM (message), "X-test1", "the value of a test"); camel_medium_add_header (CAMEL_MEDIUM (message), "X-test2", "the value of another test"); /*camel_mime_part_add_content_language (CAMEL_MIME_PART (message), g_string_new ("es-ca"));*/ camel_mime_message_set_date (message, CAMEL_MESSAGE_DATE_CURRENT, 0); camel_mime_message_set_subject (message, g_strdup ("A test message")); camel_mime_message_set_reply_to (message, g_strdup ("toto@toto.com")); camel_mime_message_set_from (message, g_strdup ("Bertrand.Guiheneuf@aful.org")); camel_mime_message_add_recipient (message, CAMEL_RECIPIENT_TYPE_TO, "Franck DeChamps", "franck.dechamps@alseve.fr"); camel_mime_message_add_recipient (message, CAMEL_RECIPIENT_TYPE_TO, NULL, "mc@alseve.fr"); camel_mime_message_add_recipient (message, CAMEL_RECIPIENT_TYPE_TO, "Richo", "richard.lengagne@inria.fr"); camel_mime_message_add_recipient (message, CAMEL_RECIPIENT_TYPE_CC, "Frank", "Francois.fleuret@inria.fr"); camel_mime_message_add_recipient (message, CAMEL_RECIPIENT_TYPE_CC, NULL, "maury@justmagic.com"); camel_mime_message_add_recipient (message, CAMEL_RECIPIENT_TYPE_BCC, "Bertie", "Bertrand.Guiheneuf@aful.org"); multipart = camel_multipart_new (); body_part = camel_mime_part_new (); camel_mime_part_set_content (CAMEL_MIME_PART (body_part), "This is a test.\nThis is only a test.\n", strlen("This is a test.\nThis is only a test.\n"), "text/plain"); camel_multipart_add_part (multipart, body_part); if (attachment_stream == NULL) { attachment_part = NULL; } else { CamelDataWrapper *attachment_wrapper; /*CamelDataWrapper *stream_wrapper; stream_wrapper = camel_stream_data_wrapper_new (attachment_stream); attachment_part = camel_mime_body_part_new (); camel_mime_part_set_encoding (CAMEL_MIME_PART (attachment_part), CAMEL_MIME_PART_ENCODING_BASE64); camel_medium_set_content_object (CAMEL_MEDIUM (attachment_part), stream_wrapper); camel_multipart_add_part (multipart, attachment_part); gtk_object_unref (GTK_OBJECT (stream_wrapper));*/ attachment_wrapper = camel_data_wrapper_new (); camel_data_wrapper_construct_from_stream (attachment_wrapper, attachment_stream); attachment_part = camel_mime_part_new (); camel_mime_part_set_encoding (CAMEL_MIME_PART (attachment_part), CAMEL_MIME_PART_ENCODING_BASE64); camel_medium_set_content_object (CAMEL_MEDIUM (attachment_part), attachment_wrapper); camel_multipart_add_part (multipart, attachment_part); } camel_medium_set_content_object (CAMEL_MEDIUM (message), CAMEL_DATA_WRAPPER (multipart)); stream = camel_stream_fs_new_with_name ("mail1.test", O_WRONLY|O_TRUNC|O_CREAT, 0600, ex); if (!stream) { printf ("Could not open output file: %s\n", camel_exception_get_description (ex)); exit(2); } camel_data_wrapper_write_to_stream (CAMEL_DATA_WRAPPER (message), stream, ex); camel_stream_flush (stream, ex); gtk_object_unref (GTK_OBJECT (stream)); if (camel_exception_is_set (ex)) { printf ("Oops. Failed. %s\n", camel_exception_get_description (ex)); exit (1); } gtk_object_unref (GTK_OBJECT (message)); gtk_object_unref (GTK_OBJECT (multipart)); gtk_object_unref (GTK_OBJECT (body_part)); if (attachment_part != NULL) gtk_object_unref (GTK_OBJECT (attachment_part)); printf ("Test1 finished\n"); return 1; } '>+6 * This module, Net::SNMP::Util, gives you functions of SNMP gettingjadawin2011-04-055-0/+44 * - Update to 2.04jadawin2011-04-053-6/+12 * - Update to 0.3.4.1novel2011-04-053-5/+10 * - update to 4.3.0dinoex2011-04-0222-475/+591 * - Remove DEPRECATEDmiwi2011-03-252-6/+2 * - Update to 3.2miwi2011-03-253-22/+27 * - Add LICENSE knob(s)mm2011-03-231-0/+2 * - Get Rid MD5 supportmiwi2011-03-20232-248/+0 * Bump PORTREVISION for ports linking to default libmysqlclient.ale2011-03-197-6/+7 * Nagios plugin to observe LDAPmiwi2011-03-187-0/+164 * FusionInventory provides a complete, modular and multi-platform solution for:miwi2011-03-185-0/+865 * - Fix build on -CURRENTpav2011-03-181-6/+3 * - Teach about python 2.7pav2011-03-181-1/+1 * hastmon is a monitoring daemon that allows a couple of hosts to run amiwi2011-03-184-0/+57 * - Update to 0.6.2miwi2011-03-173-8/+157 * Update to 0.21.15skreuzer2011-03-172-5/+5 * Update to 2011-01-R1bf2011-03-172-4/+12 * Circe is a captive portal system. It is built using Perl and is a program thatdhn2011-03-166-0/+144 * Deprecate unmaintained ports from net-mgmt where upstream disapear and/orbapt2011-03-149-0/+27 * - dbi.0 => dbi.1clsung2011-03-072-4/+4 * - Update to 2.3.6culot2011-03-043-6/+5 * - Update to 1.3.3.araujo2011-03-012-5/+3 * - Update to 1.6.3p1sylvio2011-03-012-11/+31 * - Update to 2.17.1sylvio2011-02-254-46/+3 * Chase after net/openldap24-server update.delphij2011-02-253-1/+3 * - Backout previuse commitmiwi2011-02-254-50/+8 * - Move to py25 or abovemiwi2011-02-256-12/+54 * Mark as broken on i386-8.linimon2011-02-251-0/+4 * Add Icinga, an enterprise grade open source monitoring system which keepschinsan2011-02-2417-0/+1815 * Fix a bug when using svn instead of cvsarved2011-02-232-0/+14 * - Update to 0.74wen2011-02-162-3/+3 * - Update to 0.73wen2011-02-152-3/+3 * - Update to 0.6.1miwi2011-02-143-113/+427 * - Now is possible to built this port without user interaction.araujo2011-02-145-19/+93 * Add -fstack-protector to CPPFLAGS on i386/8.x to fix build.arved2011-02-131-1/+7 * - Update to 1.5.8culot2011-02-113-3/+8 * - right swap memory statistic outputsylvio2011-02-102-18/+101 * - Proper usage of @dirrmtry macroaz2011-02-061-1/+2 * - Update to 1.4.4.miwi2011-02-054-26/+24 * - Update to 0.6miwi2011-02-056-505/+3984 * apache13 does not use etc/apache/Includes, so try to remove it on deinstall.arved2011-02-042-0/+2 * - new version of patch-memory_freebsd.csylvio2011-02-041-9/+62 * Update to 20100109arved2011-02-037-13/+314 * - Update to 1.7miwi2011-02-032-4/+3 * Update to 1.13;demon2011-01-311-0/+21 * Update to 1.13;demon2011-01-312-6/+8 * - Add disk plugin supportmiwi2011-01-314-4/+26 * - Update to 1.1miwi2011-01-313-31/+39 * - update nagios devel to current version (3.2.3)ohauer2011-01-316-415/+457 * - change MASTER_SITES to MASTER_SITE_GOOGLE_CODEohauer2011-01-313-3/+2 * - Update to 0.14miwi2011-01-302-3/+3 * Weathermap is a network visualisation tool, to take data you alreadymiwi2011-01-298-0/+342 * Update to 1.6.2arved2011-01-284-45/+7 * - Update to 0.9.7dhn2011-01-152-6/+4 * - Respect PREFIX.sem2011-01-112-1/+12 * - Fix @dirrmtry since it already filter stderr and return true and %Daz2011-01-112-2/+2 * Update to 4.038. Slightly change the minor version naming schemetobez2011-01-103-7/+3 * - Update to 0.12.5wen2011-01-103-8/+7 * - Pass maintainership to submitterdhn2011-01-102-2/+3 * - update to 0.12swills2011-01-042-5/+4 * Update to 1.0.1arved2011-01-033-7/+6 * - Use canonical format for FreeBSD.org MAINTAINER addresseserwin2011-01-032-2/+1 * Garbage-collect expired ports:rene2011-01-0115-589/+0 * - Update to 1.3.1wen2010-12-313-10/+17 * - update mainer email address (old domain no longer reachable)ohauer2010-12-318-8/+4 * net-mgmt/pnp: fix issues brought by PNP developersrea2010-12-317-60/+75 * - DISTNAME= ${PORTNAME}-${PORTVERSION} is the default and not needed.pgollucci2010-12-307-7/+0 * net-mgmt/pnp: upgrade to 0.6.10rea2010-12-295-412/+485 * Update to 0.4alphaarved2010-12-285-699/+7 * Reset krion@FreeBSD.org due to 6 months of inactivity and maintainer-linimon2010-12-281-1/+1 * Update to 0.3. This version supports SeND socket on FreeBSD 9.Xhrs2010-12-2815-249/+71 * - Fix typo, unbreakpgollucci2010-12-281-1/+1 * - Use canonical format for FreeBSD.org MAINTAINER addressessunpoet2010-12-264-4/+2 * - rackmonkey.db (sqlite) is not recreated when !INIT_DBpgollucci2010-12-232-1/+7 * - Upgrade to USERS/GROUPSpav2010-12-234-20/+180 * Sync to final (for now) bsd.autotools.mkade2010-12-232-2/+3 * For OSVERSION >= 800040, add -fstack-protector to LDFLAGSskreuzer2010-12-22