🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #13559

Re: Send a mail with attachment

#13559
From: Bob Gonder
Date: Thu, 02 Oct 2003 16:18
50 lines
2540 bytes
David Ayre wrote:

>
>I have managed to build the .lib file for the mapi32.dll and the
>programme compliles. I now have the problem that it returns an
>error code saying that logon failed.

Nothing jumped out at me, but I use 3 steps instead of your one:

>   lpMessage.flFlags = MAPI_LOGON_UI | MAPI_NEW_SESSION;
>   ULONG ulResult = MAPISendMail(0,0,&lpMessage,MAPI_NEW_SESSION,0);
>   switch(ulResult)
>   {

 LHANDLE	EmailSession;

BOOL  Logon(void)
{
if( SUCCESS_SUCCESS == 
   MAPILogon( (ULONG)hWnd, NULL, NULL, 0, 0, &EmailSession ) )
	 return TRUE;
else 
return  SUCCESS_SUCCESS == 
  MAPILogon( (ULONG)hWnd, NULL, NULL, MAPI_LOGON_UI, 0,&EmailSession);
}

void Logoff(void)
{    MAPILogoff( EmailSession, (ULONG)hWnd, 0, 0 );   
}

Usage:
if( Logon() )
{
	for( as many messages as you want to send )
	{	{.....}
		lpMessage.flFlags = MAPI_RECEIPT_REQUESTED;

		switch(	fnMAPISendMail(
			EmailSession,
			(ULONG) hWnd,           
			&msg,   
			MAPI_LOGON_UI,		// logon if needed
			0) )			
		{
		case MAPI_E_ATTACHMENT_WRITE_FAILURE:
			{......}
		};
	};
	Logoff();
};
Technical Details
Message-ID: <7lionvc9m0r2u7re2ivkok6434eegq832i@4ax.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!sn-xit-02!sn-xit-06!sn-xit-08!supernews.com!border3.nntp.aus1.giganews.com!small1.nntp.aus1.giganews.com!nntp.giganews.com!npeer.de.kpn-eurorings.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <3f70794d@newsgroups.borland.com> <3f784a32@newsgroups.borland.com> <3f79708b@newsgroups.borland.com> <3f79860c@newsgroups.borland.com> <3f799567@newsgroups.borland.com> <3f79bd46$1@newsgroups.borland.com> <3f79c517@newsgroups.borland.com> <3f79d851@newsgroups.borland.com> <3f7a8b6d$1@newsgroups.borland.com> <3f7beff9$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,23d9e1242f297072
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2003-10-02 10:25:32 PST
From: Bob Gonder <notbg@notmindspring.invalid>
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Re: Send a mail with attachment
Date: Thu, 02 Oct 2003 09:18:35 -0700
Organization: MindSpring Enterprises, Inc.
Reply-To: notbg@notmindspring.invalid
Message-ID: <7lionvc9m0r2u7re2ivkok6434eegq832i@4ax.com>
References: <3f70794d@newsgroups.borland.com> <3f784a32@newsgroups.borland.com> <3f79708b@newsgroups.borland.com> <3f79860c@newsgroups.borland.com> <3f799567@newsgroups.borland.com> <3f79bd46$1@newsgroups.borland.com> <3f79c517@newsgroups.borland.com> <3f79d851@newsgroups.borland.com> <3f7a8b6d$1@newsgroups.borland.com> <3f7beff9$1@newsgroups.borland.com>
X-Newsreader: Forte Agent 1.91/32.564
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 67.31.165.231
X-Trace: newsgroups.borland.com 1065111540 67.31.165.231 (2 Oct 2003 09:19:00 -0700)
Lines: 54
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!sn-xit-02!sn-xit-06!sn-xit-08!supernews.com!border3.nntp.aus1.giganews.com!small1.nntp.aus1.giganews.com!nntp.giganews.com!npeer.de.kpn-eurorings.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail