Page 1 of 1

WORD/OUTLOOK omail:send()

PostPosted: Fri Mar 03, 2023 10:00 am
by Otto
Hello friends,
I read that If you want to send a specific email immediately, regardless of the configuration, you can use the oMail.Send method with the True parameter. For example:

oMail.Send True

But I can't find out the Harbour syntax for oMail:Send()? How to pass TRUE.

Best regards,
Otto

Re: WORD/OUTLOOK omail:send()

PostPosted: Sat Mar 04, 2023 2:24 am
by Otto
I use the "Outlook.Application" object function to retrieve an existing instance of the Outlook application object and then use a method to send emails that are stored in the "Outbox" folder, which is where outgoing emails are temporarily stored before they are sent.

Here's an example of how you can send emails from the "Outbox" folder using theOutlook.Application-Object.
Best regards,
Otto

Code: Select all  Expand view


function Main()

   local olApp       := CreateObject( "Outlook.Application" )
   local olns        := olApp:GetNameSpace( "MAPI" )
   local oUserFolder := olns:Folders( "info@winhotel.at" )
   local oFolder     := oUserFolder:Folders( "Posteingang"  )
   local n, n2, n3, n4
   local aFolders    := {}
   local oMail
   local aEmails := {}

   // function to retrieve an existing instance of the Outlook application object
   // and then use a method to send emails that are stored in the "Outbox" folder,
   // which is where outgoing emails are temporarily stored before they are sent.

   // It then loops through all items in the "Outbox" folder and sends any email that has not been sent yet using the Send method.

   FOR n = 1 to olNS:Folders:Count
      AADD( aFolders, olNS:Folders( n ):name )

      if olNS:Folders( n ):name = "info@winhotel.at" //"otto@atzwanger.com"
         oUserFolder := olNS:Folders( n )
         FOR n2 = 1 to oUserFolder:Folders:Count
            AADD( aEmails, { oUserFolder:Folders( n2 ):name , "V E R Z E I C H N I S", oUserFolder:Folders:Count } )
            oFolder :=  oUserFolder:Folders( n2 )
            if oUserFolder:Folders( n2 ):name = "Postausgang"
               AADD( aEmails, { oFolder:name , "o F o l d e r ",  oFolder:Items:Count } )
               FOR n4 = 1 to oFolder:Items:Count
                  oMail  := oFolder:Items( n4 )
                  AADD( aEmails, { oUserFolder:Folders( n2 ):name , oMail:subject } )
                  oMail:Send()
               next
            endif
         next
      endif


   next

   xbrowse( aEmails )

return nil


 

Re: WORD/OUTLOOK omail:send()

PostPosted: Sat Mar 04, 2023 10:25 pm
by Jimmy
hi Otto,

thx for sharing yout Solution

---

as "Postausgang" is for German / AT only i recommend to use Outllok Constant
Code: Select all  Expand view
#DEFINE olFolderOutbox                          4
#DEFINE olFolderSentMail                        5
#DEFINE olFolderInbox                           6

so this should work
Code: Select all  Expand view
  aOutItem := ::oNameSpace:getDefaultFolder( olFolderOutbox ) :Items

Re: WORD/OUTLOOK omail:send()

PostPosted: Sun Mar 05, 2023 7:57 am
by Otto
Hello Jimmy, I changed my code. Thank you so much and have a nice Sunday.
Best regards,
Otto