Sending eMails automatically works with Outlook but not with Outlook Web Apps (OWA)

1.1k views Asked by At

I have a macro that automatically send emails in Outlook based on fields in an Excel file using VBA. It works really well.

The problem I'm having is the client now needs to use Outlook Web Apps (OWA). From what I have read, my macro won't work with OWA because VBA is for applications and OWA is browser based.

Is there a way to convert my macro to work with OWA? The client will have OWA open so I don't need to worry about logging in to the app.

I've read a little about CDO and tried to modify my macro but got errors (1) type mismatch when trying to attach a couple of files to the email and (2) The SendUsing configuration value is invalid.

I haven't used CDO before so I don't know what I'm doing with it.

Here is the code I tried to use:

Set OutApp = CreateObject("CDO.Message")
Set iconf = CreateObject("CDO.Configuration")

With OutApp
  Set .Configuration = iconf
  .To = Var4
  .CC = ""
  .BCC = ""
  .Subject = "Final Estate Report"
  .HTMLBody = StrBody & "<br>"
            
  A = 1
            
  OutAttach = Dir(StrDir)
            
  Do While Len(OutAttach) > 0

     DoEvents

    .Attachments.Add StrDir & OutAttach
     OutAttach = Dir
                
     A = A + 1

  Loop
  
  .Send

  Application.ScreenUpdating = True
        
End With

Any suggestions or examples of how to make this work would be greatly appreciated

Thanks for taking the time to look at this issue....

1

There are 1 answers

1
Mandivamba On

Have you looked into using Microsoft Graph. Your first task will be to call the API in VBA and you can start here How to call Microsoft Graph API using VBA . Developer documentation here