~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Wine Cross Reference
wine/dlls/mapi32/sendmail.c

Version: ~ [ wine-1.5.30 ] ~ [ wine-1.5.29 ] ~ [ wine-1.5.28 ] ~ [ wine-1.5.27 ] ~ [ wine-1.5.26 ] ~ [ wine-1.5.25 ] ~ [ wine-1.5.24 ] ~ [ wine-1.5.23 ] ~ [ wine-1.5.22 ] ~ [ wine-1.5.21 ] ~ [ wine-1.5.20 ] ~ [ wine-1.5.19 ] ~ [ wine-1.5.18 ] ~ [ wine-1.5.17 ] ~ [ wine-1.5.16 ] ~ [ wine-1.5.15 ] ~ [ wine-1.5.14 ] ~ [ wine-1.5.13 ] ~ [ wine-1.5.12 ] ~ [ wine-1.5.11 ] ~ [ wine-1.5.10 ] ~ [ wine-1.5.9 ] ~ [ wine-1.5.8 ] ~ [ wine-1.5.7 ] ~ [ wine-1.4.1 ] ~ [ wine-1.5.6 ] ~ [ wine-1.5.5 ] ~ [ wine-1.5.4 ] ~ [ wine-1.5.3 ] ~ [ wine-1.5.2 ] ~ [ wine-1.5.1 ] ~ [ wine-1.5.0 ] ~ [ wine-1.4 ] ~ [ wine-1.4-rc6 ] ~ [ wine-1.4-rc5 ] ~ [ wine-1.4-rc4 ] ~ [ wine-1.4-rc3 ] ~ [ wine-1.4-rc2 ] ~ [ wine-1.4-rc1 ] ~ [ wine-1.3.37 ] ~ [ wine-1.3.36 ] ~ [ wine-1.3.35 ] ~ [ wine-1.3.34 ] ~ [ wine-1.3.33 ] ~ [ wine-1.3.32 ] ~ [ wine-1.3.31 ] ~ [ wine-1.3.30 ] ~ [ wine-1.3.29 ] ~ [ wine-1.3.28 ] ~ [ wine-1.3.27 ] ~ [ wine-1.3.26 ] ~ [ wine-1.3.25 ] ~ [ wine-1.3.24 ] ~ [ wine-1.3.23 ] ~ [ wine-1.3.22 ] ~ [ wine-1.3.21 ] ~ [ wine-1.3.20 ] ~ [ wine-1.3.19 ] ~ [ wine-1.3.18 ] ~ [ wine-1.2.3 ] ~ [ wine-1.3.17 ] ~ [ wine-1.3.16 ] ~ [ wine-1.3.15 ] ~ [ wine-1.3.14 ] ~ [ wine-1.3.13 ] ~ [ wine-1.3.12 ] ~ [ wine-1.3.11 ] ~ [ wine-1.3.10 ] ~ [ wine-1.3.9 ] ~ [ wine-1.2.2 ] ~ [ wine-1.3.8 ] ~ [ wine-1.3.7 ] ~ [ wine-1.3.6 ] ~ [ wine-1.3.5 ] ~ [ wine-1.2.1 ] ~ [ wine-1.3.4 ] ~ [ wine-1.3.3 ] ~ [ wine-1.3.2 ] ~ [ wine-1.3.1 ] ~ [ wine-1.3.0 ] ~ [ wine-1.2 ] ~ [ wine-1.2-rc7 ] ~ [ wine-1.2-rc6 ] ~ [ wine-1.2-rc5 ] ~ [ wine-1.2-rc4 ] ~ [ wine-1.2-rc3 ] ~ [ wine-1.2-rc2 ] ~ [ wine-1.2-rc1 ] ~ [ wine-1.1.44 ] ~ [ wine-1.1.43 ] ~ [ wine-1.1.42 ] ~ [ wine-1.1.41 ] ~ [ wine-1.1.40 ] ~ [ wine-1.1.39 ] ~ [ wine-1.1.38 ] ~ [ wine-1.1.37 ] ~ [ wine-1.1.36 ] ~ [ wine-1.1.35 ] ~ [ wine-1.1.34 ] ~ [ wine-1.1.33 ] ~ [ wine-1.1.32 ] ~ [ wine-1.1.31 ] ~ [ wine-1.1.30 ] ~ [ wine-1.1.29 ] ~ [ wine-1.1.28 ] ~ [ wine-1.1.27 ] ~ [ wine-1.1.26 ] ~ [ wine-1.1.25 ] ~ [ wine-1.1.24 ] ~ [ wine-1.1.23 ] ~ [ wine-1.1.22 ] ~ [ wine-1.1.21 ] ~ [ wine-1.1.20 ] ~ [ wine-1.1.19 ] ~ [ wine-1.1.18 ] ~ [ wine-1.1.17 ] ~ [ wine-1.1.16 ] ~ [ wine-1.1.15 ] ~ [ wine-1.1.14 ] ~ [ wine-1.1.13 ] ~ [ wine-1.1.12 ] ~ [ wine-1.1.11 ] ~ [ wine-1.1.10 ] ~ [ wine-1.1.9 ] ~ [ wine-1.1.8 ] ~ [ wine-1.1.7 ] ~ [ wine-1.0.1 ] ~ [ wine-1.1.6 ] ~ [ wine-1.1.5 ] ~ [ wine-1.1.4 ] ~ [ wine-1.1.3 ] ~ [ wine-1.1.2 ] ~ [ wine-1.1.1 ] ~ [ wine-1.1.0 ] ~ [ wine-1.0 ] ~

  1 /*
  2  * MAPISendMail implementation
  3  *
  4  * Copyright 2005 Hans Leidekker
  5  *
  6  * This library is free software; you can redistribute it and/or
  7  * modify it under the terms of the GNU Lesser General Public
  8  * License as published by the Free Software Foundation; either
  9  * version 2.1 of the License, or (at your option) any later version.
 10  *
 11  * This library is distributed in the hope that it will be useful,
 12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 14  * Lesser General Public License for more details.
 15  *
 16  * You should have received a copy of the GNU Lesser General Public
 17  * License along with this library; if not, write to the Free Software
 18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 19  */
 20 
 21 #include "config.h"
 22 #include "wine/port.h"
 23 
 24 #include <stdio.h>
 25 #include <stdarg.h>
 26 
 27 #include "windef.h"
 28 #include "winbase.h"
 29 #include "winerror.h"
 30 #include "objbase.h"
 31 #include "mapi.h"
 32 #include "winreg.h"
 33 #include "shellapi.h"
 34 #include "shlwapi.h"
 35 #include "wine/debug.h"
 36 
 37 WINE_DEFAULT_DEBUG_CHANNEL(mapi);
 38 
 39 /**************************************************************************
 40  *  MAPISendMail        (MAPI32.211)
 41  *
 42  * Send a mail.
 43  *
 44  * PARAMS
 45  *  session  [I] Handle to a MAPI session.
 46  *  uiparam  [I] Parent window handle.
 47  *  message  [I] Pointer to a MAPIMessage structure.
 48  *  flags    [I] Flags.
 49  *  reserved [I] Reserved, pass 0.
 50  *
 51  * RETURNS
 52  *  Success: SUCCESS_SUCCESS
 53  *  Failure: MAPI_E_FAILURE
 54  *
 55  * NOTES
 56  *  This is a temporary hack. 
 57  */
 58 ULONG WINAPI MAPISendMail( LHANDLE session, ULONG_PTR uiparam,
 59     lpMapiMessage message, FLAGS flags, ULONG reserved )
 60 {
 61     ULONG ret = MAPI_E_FAILURE;
 62     unsigned int i, to_count = 0, cc_count = 0, bcc_count = 0;
 63     unsigned int to_size = 0, cc_size = 0, bcc_size = 0, subj_size, body_size;
 64 
 65     char *to = NULL, *cc = NULL, *bcc = NULL;
 66     const char *address, *subject, *body;
 67     static const char format[] =
 68         "mailto:\"%s\"?subject=\"%s\"&cc=\"%s\"&bcc=\"%s\"&body=\"%s\"";
 69     char *mailto = NULL, *escape = NULL;
 70     char empty_string[] = "";
 71     HRESULT res;
 72     DWORD size;
 73 
 74     TRACE( "(0x%08x 0x%08lx %p 0x%08x 0x%08x)\n", session, uiparam,
 75            message, flags, reserved );
 76 
 77     if (!message) return MAPI_E_FAILURE;
 78 
 79     for (i = 0; i < message->nRecipCount; i++)
 80     {
 81         if (!message->lpRecips)
 82         {
 83             WARN("No recipients found\n");
 84             return MAPI_E_FAILURE;
 85         }
 86 
 87         address = message->lpRecips[i].lpszAddress;
 88         if (address)
 89         {
 90             switch (message->lpRecips[i].ulRecipClass)
 91             {
 92             case MAPI_ORIG:
 93                 TRACE( "From: %s\n", debugstr_a(address) );
 94                 break;
 95             case MAPI_TO:
 96                 TRACE( "To: %s\n", debugstr_a(address) );
 97                 to_size += lstrlenA( address ) + 1;
 98                 break;
 99             case MAPI_CC:
100                 TRACE( "Cc: %s\n", debugstr_a(address) );
101                 cc_size += lstrlenA( address ) + 1;
102                 break;
103             case MAPI_BCC:
104                 TRACE( "Bcc: %s\n", debugstr_a(address) );
105                 bcc_size += lstrlenA( address ) + 1;
106                 break;
107             default:
108                 TRACE( "Unknown recipient class: %d\n",
109                        message->lpRecips[i].ulRecipClass );
110             }
111         }
112         else
113             FIXME("Name resolution and entry identifiers not supported\n");
114     }
115     if (message->nFileCount) FIXME("Ignoring attachments\n");
116 
117     subject = message->lpszSubject ? message->lpszSubject : "";
118     body = message->lpszNoteText ? message->lpszNoteText : "";
119 
120     TRACE( "Subject: %s\n", debugstr_a(subject) );
121     TRACE( "Body: %s\n", debugstr_a(body) );
122 
123     subj_size = lstrlenA( subject );
124     body_size = lstrlenA( body );
125 
126     ret = MAPI_E_INSUFFICIENT_MEMORY;
127     if (to_size)
128     {
129         to = HeapAlloc( GetProcessHeap(), 0, to_size );
130         if (!to) goto exit;
131         to[0] = 0;
132     }
133     if (cc_size)
134     {
135         cc = HeapAlloc( GetProcessHeap(), 0, cc_size );
136         if (!cc) goto exit;
137         cc[0] = 0;
138     }
139     if (bcc_size)
140     {
141         bcc = HeapAlloc( GetProcessHeap(), 0, bcc_size );
142         if (!bcc) goto exit;
143         bcc[0] = 0;
144     }
145 
146     if (message->lpOriginator)
147         TRACE( "From: %s\n", debugstr_a(message->lpOriginator->lpszAddress) );
148 
149     for (i = 0; i < message->nRecipCount; i++)
150     {
151         address = message->lpRecips[i].lpszAddress;
152         if (address)
153         {
154             switch (message->lpRecips[i].ulRecipClass)
155             {
156             case MAPI_TO:
157                 if (to_count) lstrcatA( to, "," );
158                 lstrcatA( to, address );
159                 to_count++;
160                 break;
161             case MAPI_CC:
162                 if (cc_count) lstrcatA( cc, "," );
163                 lstrcatA( cc, address );
164                 cc_count++;
165                 break;
166             case MAPI_BCC:
167                 if (bcc_count) lstrcatA( bcc, "," );
168                 lstrcatA( bcc, address );
169                 bcc_count++;
170                 break;
171             }
172         }
173     }
174     ret = MAPI_E_FAILURE;
175     size = sizeof(format) + to_size + cc_size + bcc_size + subj_size + body_size;
176     
177     mailto = HeapAlloc( GetProcessHeap(), 0, size );
178     if (!mailto) goto exit;
179 
180     sprintf( mailto, format, to ? to : "", subject, cc ? cc : "", bcc ? bcc : "", body );
181 
182     size = 1;
183     res = UrlEscapeA( mailto, empty_string, &size, URL_ESCAPE_SPACES_ONLY );
184     if (res != E_POINTER) goto exit;
185 
186     escape = HeapAlloc( GetProcessHeap(), 0, size );
187     if (!escape) goto exit;
188 
189     res = UrlEscapeA( mailto, escape, &size, URL_ESCAPE_SPACES_ONLY );
190     if (res != S_OK) goto exit;
191 
192     if ((UINT_PTR)ShellExecuteA( NULL, "open", escape, NULL, NULL, 0 ) > 32)
193         ret = SUCCESS_SUCCESS;
194 
195 exit:
196     HeapFree( GetProcessHeap(), 0, to );
197     HeapFree( GetProcessHeap(), 0, cc );
198     HeapFree( GetProcessHeap(), 0, bcc );
199     HeapFree( GetProcessHeap(), 0, mailto );
200     HeapFree( GetProcessHeap(), 0, escape );
201 
202     return ret;
203 }
204 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.