Source language: Translate to:

Sending Mail (silently) via Outlook

Questions about NeoBook PlugIns

Moderator: Neosoft Support

Sending Mail (silently) via Outlook

Postby dpayer » Tue Apr 22, 2014 11:19 am

In a corporate environment, you often don't have SMTP servers you can use for applications but all the employees use Outlook and Exchange for email.

I had a project that required sending emails at every step of a process. David@Argentina pointed me to a VBS that worked to do that in Outlook.

I was able to adapt it as a NB function but it requires that Outlook be running (even if only minimized) to actually send the mail. So I created a subroutine to check if Outlook was running (in a known location) and if not I would run it minimized. I called the function from the subroutine and all works well.

The list of addresses this is sent to must be a string with the values separated by a semi-colon.

Hope this is helpful to someone.

Subroutine:
Code: Select all

.see if Outlook is running
Run "cmd.exe" "/c [#34] tasklist | clip[#34]" "RunOnce+Hidden" "" ""
SearchStr "OUTLOOK.EXE" "[Clipboard]" "[foundoutlook]" ""
If "[foundoutlook]" "=" "0"
.if not running and if [outlookloc] hasn't been set yet
     If "[OutlookLOC]" "=" ""
       FileExists "C:\Program Files (x86)\Microsoft Office\Office12\OUTLOOK.EXE" "[FoundOutlook]"
         If "[FoundOutlook]" "=" "True"
           SetVar "[OutlookLOC]" "C:\Program Files (x86)\Microsoft Office\Office12\OUTLOOK.EXE"
          Else
            FileOpenBox "Find Outlook.exe" "OUTLOOK.EXE" "c:\program files (x86)\Microsoft Office\" "[OutlookLOC]" ""
          Endif
      Endif
    Run "[outlookloc]" "" "RunOnce+Minimized" "" ""
Endif

Call "SendMail_via_Outlook" "[Email_Recipients]" "[ESubject]" "[Ebody]"



Function (name:Sendmail_via_Outlook):
Code: Select all
{NeoBook Function}
Version=5.80
Language=VBScript
Param=[%1]|Text|Email addresses, separated by semi colon
Param=[%2]|Text|Email Subject
Param=[%3]|Text|Email Body - in HTML
{End}
Set objOutlook = CreateObject("Outlook.Application")
   Set objMail = objOutlook.CreateItem(0)
   objMail.to = [%1]
   objMail.Subject = [%2]
   objMail.HTMLBody = [%3]

   objMail.Send
   Set objMail = Nothing
   Set objOutlook = Nothing

David Payer
Des Moines, Iowa
USA
User avatar
dpayer
 
Posts: 1380
Joined: Mon Apr 11, 2005 5:55 am
Location: Iowa - USA

Re: Sending Mail (silently) via Outlook

Postby mishem » Tue Apr 22, 2014 11:36 am

C:\Program Files (x86)\Microsoft Office\Office12\OUTLOOK.EXE


[ProgramFiles]Microsoft Office\Office12\OUTLOOK.EXE
?
mishem
 
Posts: 574
Joined: Mon Oct 08, 2012 1:51 pm

Re: Sending Mail (silently) via Outlook

Postby dpayer » Tue Apr 22, 2014 1:21 pm

mishem wrote:
C:\Program Files (x86)\Microsoft Office\Office12\OUTLOOK.EXE


[ProgramFiles]Microsoft Office\Office12\OUTLOOK.EXE
?


ProgramFiles variable. I am not sure if it uses c:\program files OR c:\program files (x86)

I did a direct link on that subroutine. If it didn't find it the application, it would ask for the user to find it.

David P.
David Payer
Des Moines, Iowa
USA
User avatar
dpayer
 
Posts: 1380
Joined: Mon Apr 11, 2005 5:55 am
Location: Iowa - USA

Re: Sending Mail (silently) via Outlook

Postby DaveJ » Thu Apr 24, 2014 3:56 pm

Hi Dave,

Not sure if this will help but this registry key holds the default mail client including the path

HKEY_LOCAL_MACHINE\SOFTWARE\Classes\mailto\shell\open\command

Mine looks like this ; "C:\PROGRA~2\MICROS~1\Office14\OUTLOOK.EXE" -c IPM.Note /m "%1"

So just run C:\PROGRA~2\MICROS~1\Office14\OUTLOOK.EXE

Good luck

Dave J
DaveJ
 
Posts: 90
Joined: Tue Dec 30, 2008 11:06 am


Return to PlugIn Discussions

Who is online

Users browsing this forum: No registered users and 1 guest

cron