ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Can't close e-mail (https://www.excelbanter.com/excel-programming/342563-cant-close-e-mail.html)

Brian Delaney

Can't close e-mail
 
Hi,

From code I've seen in posts, I can't figure out why this won't work: can't
get the e-mail to close after it's been sent.

Dim Out As Outlook.Application, EM As MailItem

Set Out = New Outlook.Application

Set EM = Out.CreateItem(olMailItem)
With EM
.To = "Joe Smith"
.Subject = Range("A9").Value
.HTMLBody = Range("A11").Value & " " & Range("B11").Value
.display
.send
.Close
End With

This works fine until I include the .Close line. Then I get "Argument Not
Optional" (referring to .Close) and the procedure won't run.

Can anyone help? Thanks in advance,

Brian



William Benson[_3_]

Can't close e-mail
 
I don't understand why you have .display and .send in the same procedure.
Can't you just send it (if you don't want to view it) and if you do want to
view it, why not just send it manually?

"Brian Delaney" wrote in message
...
Hi,

From code I've seen in posts, I can't figure out why this won't work:
can't get the e-mail to close after it's been sent.

Dim Out As Outlook.Application, EM As MailItem

Set Out = New Outlook.Application

Set EM = Out.CreateItem(olMailItem)
With EM
.To = "Joe Smith"
.Subject = Range("A9").Value
.HTMLBody = Range("A11").Value & " " & Range("B11").Value
.display
.send
.Close
End With

This works fine until I include the .Close line. Then I get "Argument Not
Optional" (referring to .Close) and the procedure won't run.

Can anyone help? Thanks in advance,

Brian





All times are GMT +1. The time now is 03:48 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com