Outlook Randomly Not attaching (attachment file)

Outlook not attaching code 100% of the time

  • .

    Votes: 0 0.0%
  • .

    Votes: 0 0.0%

  • Total voters
    0
Status
Not open for further replies.

Peter Berlin

Member
Outlook version
Outlook 2013 64 bit
Email Account
POP3
Hello. I am using Office 2013. I have excel vba working great except for outlook doesn't attach the file 100% of the time. Sometimes it attaches and sometimes it doesn't. It only acts up for remote (out of the office) individuals. The excel macro runs and attaches an email in outlook and saves it to the draft folder. Do I need to add a sleep command before and after the attachment code? Code is attached. Thanks, Peter

Code:
Dim OutApp As Object
    Dim OutMail As Object

    Set OutApp = CreateObject("Outlook.Application")
    Set OutMail = OutApp.CreateItem(0)
   

    On Error Resume Next
    With OutMail
    .SentOnBehalfOfName = "abc@abc.com"
    '.Display
        .To = dis_contacts
        .cc = rok_contacts
        .BCC = ""
        '.Subject = "Agreement #" & Temp & " Pre Pop Form (" & strDistrict & " - " & expr_date & ")" & " Distributor: " & strDistributor & " Customer: " & cust_name
        .Subject = "Agreement #" & Temp & " Pre Pop (" & strBO & " - " & expr_date & ") " & " Customer: " & strCustomerID & " - " & cust_name & "  Distributor: " & strDistributorID & " - " & strDistributorName
       
        'SPA 4000****** Pre Pop (SubRegion - Exp Date) 99xxxxxx Customer Name 99xxxxxx APRxxx Distributor Name
       
        Dim sMsgBody As String
    sMsgBody = "......" & vbCr & vbCr
    sMsgBody = sMsgBody & "I......" & vbCr
    sMsgBody = sMsgBody & " " & vbCr
   
    .body = sMsgBody

Sleep (9000)
    .Attachments.Add (dbfile)
    .Display
Sleep (9000)
    .Save
    .Close olPromtForSave
    End With
    On Error GoTo 0

    Set OutMail = Nothing
    Set OutApp = Nothing
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
M Outlook 2016 Outlook randomly unhides from taskbar Using Outlook 12
O Outlook 2013 deleting emails randomly Using Outlook 0
B Outlook 2003 randomly not auto forwarding Using Outlook 0
S Outlook 2007 Rules randomly stopping working (non-Exchange Server) Using Outlook 6
D Outlook 2010 randomly does not receive emails Using Outlook 3
F outlook 2010 favorite folder items randomly appearing / disappearing Using Outlook 1
S Type Randomly Enlarging in Email Messages in Outlook 2010 Using Outlook 7
N Email Font randomly huge when received Outlook 2007 Using Outlook 16
B SelectionChangeEventHandler randomly disappears in Outlook 2007 Outlook VBA and Custom Forms 1
witzker Open Contact missing in Outlook 2019 Using Outlook 2
D.Moore VB script to Digitaly Sign newly created outlook message Outlook VBA and Custom Forms 2
B Outlook 2016 Retail C2R keeps logging since update? Using Outlook 0
M outlook 365 trying to finish my sentences Using Outlook 0
D Outlook Address Book Using Outlook 0
B Emails get stuck in Outbox of Gmail IMAP in Outlook for Windows Using Outlook 0
C Not sync folders not found after MS Outlook 365 update Using Outlook 1
V Outlook 2016 Does Outlook-2016 (64 bit) work with iCloud for Windows ? Using Outlook 4
R Microsoft Outlook 2016 - Gmail not sending, asks for password for SMTP, tried different ports Using Outlook 23
V Outlook 2016 Outlook-2016 and iCloud for Windows - Problems Using Outlook 2
O VBA Outlook Message Attachment - Array Index Out of Bounds Outlook VBA and Custom Forms 0
K Imap PC Outlook + Android phone Using Outlook 1
GregS Outlook 2016 Move Outlook to new computer? Using Outlook 4
I Outlook 2003 shows html code when To: field is empty Using Outlook 7
O The Outlook API wrongfully shows an outlook folder to have zero sub-folders Outlook VBA and Custom Forms 1
O The Outlook API wrongfully shows an outlook folder to have zero sub-folders Outlook VBA and Custom Forms 2
C All Gmails don't show in Outlook 2019 Using Outlook 3
D Outlook 2007 vs. Outlook 2010 -- ToDo Bar Using Outlook 0
U Outlook 2016 Outlook 2016 sender name Using Outlook 1
T Compuserve, Yahoo, Oath2 and Outlook 2013 Using Outlook 4
E Work uses live accounts for emails for all employees. Can we use the outlook calendar to give the employees an universal work schedule calendar? Using Outlook 1
witzker Macro to move @domain.xx of a Spammail to Blacklist in Outlook 2019 Outlook VBA and Custom Forms 6
D Outlook 2007 on 365 Using Outlook.com accounts in Outlook 2
S Macro for other actions - Outlook 2007 Outlook VBA and Custom Forms 23
P outlook 2008 search box criteria couldn't be saved Using Outlook 2
pcunite Outlook 2019/O365 Build 13127.20408 errors when using MAPI calls Using Outlook 1
C Outlook with Office365 - search across account, by date rate, in multiple folders - how? Using Outlook 2
D Outlook 2010 Outlook in Windows 10 keeps asking for user name and password repeatedly Using Outlook 14
S Outlook mail adressing stops after first match in GAL Using Outlook 0
A Apply Selected Emails to outlook rules and Run Rules Using Outlook 5
T Changing Sent Items location in Outlook 2019 Using Outlook 0
J How do I disable advertising in Outlook 2019? Using Outlook 13
S Outlook (2016 32bit; Gmail IMAP) - Save sent message to Outllook Folder Outlook VBA and Custom Forms 0
L Unable to Sync Web/Android MS To Do with Windows Outlook Tasks Using Outlook 3
S Macro to move “Re:” & “FWD:” email recieved the shared inbox to a subfolder in outlook Outlook VBA and Custom Forms 0
S Outlook Macro to send auto acknowledge mail only to new mails received to a specific shared inbox Outlook VBA and Custom Forms 0
S Outlook Macro to move reply mail based on the key word in the subjectline Outlook VBA and Custom Forms 0
B Outlook Calendar not coming down from cloud Using Outlook 2
Terry Sullivan Sender's Name Doesn't Appear in the From Field on Outlook 365/IMAP Using Outlook 2
GregS Outlook 2016 Can I disable the Outlook Outbox? Using Outlook 2
P Outlook pst file is too huge with POP3. How to save more space? Using Outlook 4

Similar threads

Top