Outlook won't send e-mail when offline

Outlook version
Outlook 2013 64 bit
Email Account
Office 365 Exchange
#1
I have this code, which is working fine, except if you don't have internet connection.
The problem is that Outlook doesn't send it when internet connection is back.
It doesn't appear in the Outbox folder either

So is there a way to send it automatically later?


Code:
Private Sub Application_Startup()
Dim objMsg As MailItem
Set objMsg = Application.CreateItem(olMailItem)
 With objMsg
  .To = "name@domain.ext"
  .CC = ""
  .BCC = ""
  .Subject = "Subject"
  .Body = "Body"
  .Send
End With

Set objMsg = Nothing
End Sub
 
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
#4
You're using an Exchange mailbox in cached mode, right? (Online mode shouldn't even open if offline.)
 
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
#5
it's going into the outbox here... add msgbox "message created" at the end of your macro - does the message box come up?
offline.png
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
#8
Security settings weren't changed? (Shouldn't have been, otherwise it would fail manually too.)
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
#9
Add a msgbox as the first line - then restart outlook.

Private Sub Application_Startup()
MsgBox "Sending new message"
Dim objMsg As MailItem
 
Outlook version
Outlook 2013 64 bit
Email Account
Office 365 Exchange
#10
Nope. It doesn't work.
Strange thing. Macros are enabled in security settings
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
#11
In the VBA editor, go to tools, options - General tab. Is break on all errors selected?
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
#12
(A gal can learn to hate edge - ever since the last windows update, about half the time, Enter posts replies instead of just adding a new line). Damn, shift enter does it too. Back to chrome. :)

This is what I'm trying, but not very successfully, to post:
break-errors.png
 
Outlook version
Outlook 2013 64 bit
Email Account
Office 365 Exchange
#13
(A gal can learn to hate edge - ever since the last windows update, about half the time, Enter posts replies instead of just adding a new line). Damn, shift enter does it too. Back to chrome. :)

This is what I'm trying, but not very successfully, to post:
View attachment 2237
Nope. The last one is checked "Break on Unhandled Errors".
Should i check the first one?

P.S. About the new line, try shift + enter
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
#14
Nope. The last one is checked "Break on Unhandled Errors".
Should i check the first one?
Yes, try the first one.

I have tried shift+enter - it works on some forums, but here it just sends too. Toggling BB code (gear icon) fixes it. It must be an issue with editors - i have a similar experience with WordPress when i use the rich text editor. Fortunately, i don't use it often - mostly just when i need to create a numbered list.
 
Outlook version
Outlook 2013 64 bit
Email Account
Office 365 Exchange
#17
So no errors if you are breaking on all errors?
Yep no errors. Actually it worked few times. But other macros are stopping because of an error (like trying to create folder that already exist).

I'm starting to think that may be the problem is in the VBA handler. This is company laptop, part of domain with a lot of restrictions
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
#18
Actually it worked few times. But other macros are stopping because of an error (like trying to create folder that already exist).
If it worked before, it should still unless the corp put out a new gpo that blocks macros.

You can check to see if a folder exists:

Dim objNewFolder As Outlook.Folder
Set objNewFolder = objParentFolder.Folders(newFolderName)

If objNewFolder Is Nothing Then
Set objNewFolder = objParentFolder.Folders.Add(newFolderName)
End If
 
Outlook version
Outlook 2013 64 bit
Email Account
Office 365 Exchange
#19
Code:
saveFolder = "D:\Desktop\TMP\"
RSubject = Replace(itm.Subject, ":", "_")
RSubject = Replace(RSubject, ",", "_")
RSubject = Replace(RSubject, "/", "_")
RSubject = Replace(RSubject, "\", "_")

MkDir saveFolder
I meant windows directory, not Outlook. If i remember correctly it was such a pain in the *ss to check if folder exist and it's easier just to create it (or at least to try to)
 

Similar threads

Top