ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   email help please!! (https://www.excelbanter.com/excel-programming/333701-email-help-please.html)

ricksimm[_4_]

email help please!!
 

Private Sub ContinueButton_Click()
Dim OutApp As Outlook.Application
Dim OutMail As Outlook.MailItem

Unload EmailProgress
Application.DisplayAlerts = False
Application.ScreenUpdating = False
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(olMailItem)
On Error GoTo cleanup
With OutMail
.To = Sheets("Email").Cells(1, 2).Value
.Subject = emSubject
.Body = emBody
i = 1
Do While Sheets("Email").Cells(i, 3) < "" And i < 10
.Attachments.Add Sheets("Email").Cells(i
3).Value
i = i + 1
Loop
.Send
End With

' rename emailed files from SEND to SENT
i = 1
Do While Sheets("Email").Cells(i, 3).Value < "" And i < 20
SaveIt = Sheets("Email").Cells(i, 3).Value
emName = Replace(Sheets("Email").Cells(i, 3).Value
"Send", "Sent")
Name SaveIt As emName
i = i + 1
Loop
cleanup:
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub


This code sends multiple txt files as attachments to one email and the
moves the files to a different folder. It works except for th
following. If Outlook is already running at the time, the Outloo
window opens and the email is sent. It does not return to excel. I hav
to click on excel in the taskbar to reenter my program. As you ca
probably guess the email process works ok if Outlook is not alread
running except I never lose control of the screen. Is there a way t
stop the required manual interventiion?? As a side note, the "sendin
message in your behalf" Outlook message is automatically clicked yes b
the resident ClickYes utility. Thanks
Edit/Delete Messag

--
ricksim
-----------------------------------------------------------------------
ricksimm's Profile: http://www.excelforum.com/member.php...fo&userid=2189
View this thread: http://www.excelforum.com/showthread.php?threadid=38475



All times are GMT +1. The time now is 05:07 AM.

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