Page 1 of 1
FWH MAIL - MAPI
Posted: Mon Dec 12, 2016 9:44 pm
by TimStone
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
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
Re: FWH MAIL - MAPI
Posted: Wed Dec 14, 2016 5:40 pm
by dtussman
I am able to send unattended emails through Outlook using CDO. You just have to set the port to 25.
Re: FWH MAIL - MAPI
Posted: Wed Dec 14, 2016 5:53 pm
by TimStone
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
Re: FWH MAIL - MAPI
Posted: Mon Jul 17, 2017 9:21 am
by gkuhnert
Tim,
maybe this code helps you in any way sending mails via Outlook:
Code: Select all
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
Re: FWH MAIL - MAPI
Posted: Mon Jul 17, 2017 10:14 am
by Marc Venken
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
Re: FWH MAIL - MAPI
Posted: Mon Jul 17, 2017 10:15 am
by Marc Venken
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
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
Re: FWH MAIL - MAPI
Posted: Mon Jul 17, 2017 10:38 am
by gkuhnert
Marc,
did you already try to use the TMail Class?
Code: Select all
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!
Re: FWH MAIL - MAPI
Posted: Mon Jul 17, 2017 11:30 am
by Marc Venken
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
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
Re: FWH MAIL - MAPI
Posted: Mon Jul 17, 2017 12:59 pm
by gkuhnert
Marc,
sorry, I never used TPOP3, maybe someone else can help?
Re: FWH MAIL - MAPI
Posted: Mon Jul 17, 2017 3:27 pm
by James Bott
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