Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

send mail coding doesnt always work

Status
Not open for further replies.

robcarr

Programmer
May 15, 2002
633
GB
Hi,

I have this coding to send emails, and sometimes it does not send, is there anyway to check if it has sent, and if it has not sent then make sure it has been sent.

Code:
Set objMail = Nothing
Set objol = Nothing
Set objol = Outlook.Application
Set objMail = objol.CreateItem(olMailItem)
With objMail
  .To = "whoever"
    .Subject = "Daily Flash Report update for " & Format(Now() - 1, "dd-mmm") & "."
     .Body = "Hi," & vbCrLf _
    & "Please find attached the Flash Report" & vbCrLf & vbCrLf _
    & "This report has been automatically generated, please check before sending to clients. " & vbCrLf & vbCrLf _
    & "if you have any queries can you please let me know." & vbCrLf & vbCrLf _
     & "Regards" & vbCrLf
.Attachments.Add pname
    .Display
    SendKeys "%{s}", True
End With
Set objMail = Nothing
Set objol = Nothing
End If

also I have not tried yet but do I need to have the display to send using this way of sending.

thanks in advance.

Hope this is of use, Rob.[yoda]
 
You may use the AppActivate instruction before calling SendKeys

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
tahnks phv, will try this and see what happens tomorrow (next run date),

do you believe i need the display line?

Hope this is of use, Rob.[yoda]
 
If you don't care "Outlook Object Model Guard" you may replace this:
.Display
SendKeys "%{s}", True
with this:
.Send

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top