FWH MAIL - MAPI

FWH MAIL - MAPI

Postby TimStone » Mon Dec 12, 2016 9:44 pm

I am able to use FWH MAIL / MAPI successfully with Outlook. Anytime I send an email in my application, it opens in Outlook and allows me to send it. I simply call this function within my program:

Code: Select all  Expand view

FUNCTION SendMAPIMail2( MailTo, cSndFile, cText, cSubj )
    // Send MAPI mail originates email to the MAPI client
    //  Updated:    8/2/2015 2:16:52 PM
    LOCAL oMail
      DEFINE MAIL oMail ;
         SUBJECT cSubj ;
         TEXT cText ;
         FILES cSndFile, cSndFile ;
         FROM USER ;
         TO MailTo
      ACTIVATE MAIL oMail
RETURN( .t. )
 


This is great for individual emails. However, I have a need to send out emails, using MAPI, unattended. I may be sending 30 emails, and I do not want them to display in Outlook and wait for a response. They just need to go out. Of course I can do this with SMTP, etc. but Outlook would be far more productive.

Is there a setting or code that can be used to simply have Outlook pass through the emails ?

Tim
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2897
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: FWH MAIL - MAPI

Postby dtussman » Wed Dec 14, 2016 5:40 pm

I am able to send unattended emails through Outlook using CDO. You just have to set the port to 25.
dtussman
 
Posts: 97
Joined: Sat Jun 06, 2015 6:57 pm

Re: FWH MAIL - MAPI

Postby TimStone » Wed Dec 14, 2016 5:53 pm

I use CDO direct to an SMTP server, but have not seen it use Outlook.

I have 3 options.
1) SMTP
2) CDO
3) MAPI

The first two go directly to the SMTP server. However, there are some advantages to using MAPI. The problem is that it brings up outlook each time. That is fine for individual emails, but if I'm sending a group of emails automatically, it won't work out.

Maybe you could share some code on how you use CDO with Outlook ?

Tim
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2897
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: FWH MAIL - MAPI

Postby gkuhnert » Mon Jul 17, 2017 9:21 am

Tim,

maybe this code helps you in any way sending mails via Outlook:

Code: Select all  Expand view
static function SendTestMail()
local oMail := CreateOutlookMail()
    oMail:Send()
return .t.

static function CreateOutlookMail()
local oItem
local oOutlook := GetOutlookObject()
    oItem := osOutlook:Application:CreateItem(0)
    oItem:Subject := "Mail to myself"
    oItem:Body := "Body of my testmail"
    oItem:Recipients():Add("...") // your recipient here!
return oItem

static function GetOutlookObject()
local oOutlook
    TRY
        oOutlook := GetActiveObject ( "Outlook.Application" )
    CATCH
        TRY
        oOutlook := CREATEOBJECT( "Outlook.Application" )
        CATCH
                MsgStop("Cannot start outlook!")
                return nil
            END
        END
    ENDIF
return oOutlook
 
Best Regards,

Gilbert Kuhnert
CTO Software GmbH
http://www.ctosoftware.de
User avatar
gkuhnert
 
Posts: 274
Joined: Fri Apr 04, 2008 1:25 pm
Location: Aachen - Germany // Kerkrade - Netherlands

Re: FWH MAIL - MAPI

Postby Marc Venken » Mon Jul 17, 2017 10:14 am

Tim,

If you leave out the

From User

in the program, it send by outlook, but with no action from the user. If that is what you mean.
The mails are however in the outbox, and you don't want that ?

Marc
Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1338
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: FWH MAIL - MAPI

Postby Marc Venken » Mon Jul 17, 2017 10:15 am

Is this also possible for Thunderbird and others ?

Marc


gkuhnert wrote:Tim,

maybe this code helps you in any way sending mails via Outlook:

Code: Select all  Expand view
static function SendTestMail()
local oMail := CreateOutlookMail()
    oMail:Send()
return .t.

static function CreateOutlookMail()
local oItem
local oOutlook := GetOutlookObject()
    oItem := osOutlook:Application:CreateItem(0)
    oItem:Subject := "Mail to myself"
    oItem:Body := "Body of my testmail"
    oItem:Recipients():Add("...") // your recipient here!
return oItem

static function GetOutlookObject()
local oOutlook
    TRY
        oOutlook := GetActiveObject ( "Outlook.Application" )
    CATCH
        TRY
        oOutlook := CREATEOBJECT( "Outlook.Application" )
        CATCH
                MsgStop("Cannot start outlook!")
                return nil
            END
        END
    ENDIF
return oOutlook
 
Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1338
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: FWH MAIL - MAPI

Postby gkuhnert » Mon Jul 17, 2017 10:38 am

Marc,

did you already try to use the TMail Class?

Code: Select all  Expand view

oMail:=TMail():New()
oMail:cSubject:="your subject"
oMail:aRecipients:={"..."} // your recipient(s)
oMail:cNoteText:= "your text"
oMail:Activate()
oMail:End()
 


I've never made a special routine for thunderbird, but some of our customers say that our general routine works fine for them. Thunderbird has to be the standard mail program though!
Best Regards,

Gilbert Kuhnert
CTO Software GmbH
http://www.ctosoftware.de
User avatar
gkuhnert
 
Posts: 274
Joined: Fri Apr 04, 2008 1:25 pm
Location: Aachen - Germany // Kerkrade - Netherlands

Re: FWH MAIL - MAPI

Postby Marc Venken » Mon Jul 17, 2017 11:30 am

Gilbert,

Never used it. I have a app. where I use it the same way as mentioned by Tim above.

Will look into it, because it seems to have much more options.

For reading is the pop3 class ok ? I can read mails with it, but it always deletes them on the server, even If I put
oInMail:lDelMsgs := .F. //


Code: Select all  Expand view

function GetMail()

   local oInMail

   oWnd:SetMsg( "Geting Internet email..." )

   oInMail = TPop3():New( "194.224.203.2",, "<Your username>", "<Your password>" )  // mail server IP

  oInMail:lDelMsgs  := .F.  //

   oInMail:bConnecting = { || oWnd:SetMsg( "Connecting to 194.224.203.2..." ) }
   oInMail:bConnected  = { || oWnd:SetMsg( "Connected" ) }
   oInMail:bDone       = { || ReadEmails( oInMail ) }

   oInMail:GetMail()

return nil

//----------------------------------------------------------------------------//

function ReadEmails( oInMail )

   local n

   MsgInfo( "Total emails: " + Str( Len( oInMail:aMsgs ) ) )

   for n = 1 to Len( oInMail:aMsgs )
      MsgInfo( oInMail:aMsgs[ n ] )
   next

return nil
 





Marc
Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1338
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: FWH MAIL - MAPI

Postby gkuhnert » Mon Jul 17, 2017 12:59 pm

Marc,

sorry, I never used TPOP3, maybe someone else can help?
Best Regards,

Gilbert Kuhnert
CTO Software GmbH
http://www.ctosoftware.de
User avatar
gkuhnert
 
Posts: 274
Joined: Fri Apr 04, 2008 1:25 pm
Location: Aachen - Germany // Kerkrade - Netherlands

Re: FWH MAIL - MAPI

Postby James Bott » Mon Jul 17, 2017 3:27 pm

Marc,

Did you see my response to your testing on the other thread. I'm pretty sure it is your test routine that is the problem and the mails are still there.

James
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 7 guests