This page provides information on use of utility Command line email in Microsoft Word VBA macro (Visual Basic for Applications). By using febooti Command line email you can:

  • Send email message using plain text or HTML message with embedded pictures.
  • Send unlimited number of attachments.
  • Use return codes to check success or failure.
  • Works on Microsoft Windows (98 / Me / NT / 2000 / 2003 / XP / Vista) including all server versions.
  • And many more options...

Sample MS Word VB script:

Sub sending_email()
  ' Send Word e-mail and output the result.

  Dim server
  Dim subj
  Dim body
  Dim command

  ' Define all email parameters.

  server = " smtp.sender.com -PORT 25"
  subj = "WORD mail"

  body = """This is <I>HTML / MIME</I> e-mail message "
  body = body & "sent from MS WORD VB script<BR>"
  body = body & "using <B>febooti Command line email</B>"""

  command = "febootimail.exe -HTML -FROM ms-word-macro@sender.com "
  command = command & "-TO john@sender.com "
  command = command & "-SUBJ " & subj & " -BODY " & body & server

  ' Passing one long line to Scripting object.
  ' If there is need to add aditional parameters, do it before.


  Set wsShell = CreateObject("wscript.shell")
  Set proc = wsShell.Exec(command)

  ' Wait until e-mail is sent...
  ' Implementing delay with loop.
  ' This is one of many possible methods.


  Do While proc.Status = 0
    For i = 1 To 1000
      ' Empty loop...
    Next i
  Loop

  ' Alternatively you can implement delay using API Call.
  ' In General Declarations section put:
  ' Declare Sub Sleep Lib "kernel32" Alias "Sleep" (ByVal dwMs As Long)

  ' Then in VBA code add following line:
  ' Sleep 1000 ' Sleeping 1 second


  Dim s: s = ""
  ' Use proc.ExitCode to check for returned %errorlevel%
  s = s & "StdOut=" & proc.StdOut.ReadAll()
  s = s & Chr(13) & Chr(10) & "ExitCode=" & proc.ExitCode
  MsgBox (s)

  Set wsShell = Nothing
  Set proc = Nothing

  ' Error Level values and descriptions are available at:
  ' www.command-line-email.com/online-help/batch-file-errorlevel.html

End Sub 
Additional Command line email notes and resources:

Please do not hesitate to contact our support department with any possible further questions or to solve practical issues connected with Command line email.