View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Daveh Daveh is offline
external usenet poster
 
Posts: 30
Default send email macro with Outlook running

I have a small macro that runs in Excel that will attach a file and emails
the attachment. Runs fine when Outlook is not running, but I have problems
when Outlook is already running. (runtime error ) and excel complains as
well.
Code looks like this:
Set OutlookApp = CreateObject("Outlook.Application")
Set OutlookMail = OutlookApp.CreateItem(0)
Set NSpace = OutlookApp.GetNamespace("MAPI")
OutlookMail.To = MailArchiveAddress 'EmailID
OutlookMail.Subject = " File Upload from: " & Name
OutlookMail.Body = "Calibration UpLoad File"
OutlookMail.Attachments.Add MailAttach ' attachment filename
OutlookMail.Display
set OutlookMail = Nothing
set OutlookApp = Nothing