README Send Email Without Attachments

README Send Email Without Attachments #

What this does #

Sends an email as the authenticated user via the Microsoft Graph /me/sendMail endpoint, using OAuth2 with MFA. Supports To, CC, and BCC address lists (comma- or semicolon-separated), plain text or HTML body, and the option to save a copy to Sent Items.

Note: Before sending, you may wish to check your recipient addresses against the user’s personal Exchange contacts folder. See the Validate Contacts module for that capability.

Office apps #

  • Access (tested M365)
  • Excel (untested M365)

Required components #

  • VBAuth.dll v1.x
  • modVBAuthGlobalConstants.bas (from /shared)
  • modSendEmail.bas (this module)

Azure Entra App Registration #

Delegated permissions:

  • Mail.Send

VBAuth Admin Table – Required Values #

Column NameRequired Value / ExampleNotes
AppID4Identifies this feature’s configuration record
ActionNameVBAuth – Send EmailDisplay name — any value acceptable
ClientID(your App Client ID)GUID from Azure App Registration Overview blade
TenantID(your Tenant ID)GUID from Azure App Registration Overview blade
ObjectID(your Object ID)Set by PopulateMissingObjectIDs — shared registration with Validate Contacts (AppID=3)
ScopeClaimsMail.Send,Contacts.ReadComma-separated Graph scopes — shared registration with Validate Contacts (AppID=3)
VerbPOSTHTTP method
URLPart1https://graph.microsoft.com/v1.0/me/sendMailGraph endpoint
URLParameter1NO VALUE REQUIREDNot used
URLPart2NO VALUE REQUIREDNot used
URLParameter2NO VALUE REQUIREDNot used
URLPart3NO VALUE REQUIREDNot used
WaitForLogin60Seconds — NB MSXML2 timeout parameters are in milliseconds

Module: modSendEmail.bas #

Design note: This module separates payload construction from sending into two public functions. This is intentional — the sendMail JSON payload can be complex, so BuildSendMailPayload is exposed publicly to allow callers to inspect, log, or modify the payload before sending. The typical calling pattern is: call BuildSendMailPayload first, then pass the result directly to SendEmail.

Public functions #

SendEmail(strPayload As String, ByRef strResult As String) As Boolean
Code language: JavaScript (javascript)

Acquires a bearer token for the configured AppID, then POSTs the supplied JSON payload to the Graph /me/sendMail endpoint. Returns True on HTTP 202 (accepted). Returns False on any other HTTP status or error, with strResult containing the error detail.

BuildSendMailPayload(strTo, strCC, strBCC, strSubject, strBody, blnBodyHTML, blnSaveToSentItems) As String
Code language: JavaScript (javascript)

Constructs the JSON request body from the supplied field values. strTo, strCC, and strBCC are comma- or semicolon-separated address lists. blnBodyHTML sets the body content type to HTML if True, plain text if False. blnSaveToSentItems controls whether a copy is saved to the user’s Sent Items folder. Returns the complete JSON string ready to pass to SendEmail.

Typical calling pattern #

Dim strPayload  As String
Dim strResult   As String

strPayload = BuildSendMailPayload(strTo, strCC, strBCC, strSubject, strBody, False, True)
If SendEmail(strPayload, strResult) Then
    MsgBox "Sent.", vbInformation
Else
    MsgBox "Failed: " & strResult, vbCritical
End If
Code language: PHP (php)

Behaviour #

  • Sends email as the authenticated (signed-in) user — not as a service account
  • Graph returns HTTP 202 on success with no response body
  • A network timeout returns a descriptive error message — timeout duration is controlled by lngHTTPTimeout in modVBAuthGlobalConstants.bas
  • Special characters in subject and body (backslash, double-quote, CR/LF, tab) are escaped automatically by JsonEscape before the payload is built
  • Requires interactive sign-in — application permissions are not supported

Notes #

  • Does not support application permissions
  • CC and BCC are optional — pass an empty string for any field not required
  • The Graph API does not provide delivery confirmation — HTTP 202 means the message was accepted for delivery, not that it was delivered

VBAuth, developed and maintained by Andrew Richards (The IT Service Ltd) and Peter Bryant (Corylus Business Systems), © 2025–2026. All rights reserved. https://vbauth.com

Updated on April 3, 2026