Outlook unable to open

chintu

New Member
Joined
Apr 1, 2018
Messages
17
Hi Team,

I am trying to use the below VBA Code to generate the outlook Draft report with attachment, however was unable to do so. Please navigate me to the correct coding:

Sub SEND_EMAIL_WITH_FILE()
On Error Resume Next
Sheet6.Activate
Dim Otl As Outlook.Application
Set Otl = New Outlook.Application
Dim otlmail As Outlook.MailItem

Dim i As Long

For i = 15 To Range("A150").End(xlUp).Row
If Cells(i, 6).Value = "yes" Then
Set otlmail = Otl.CreateItem(olMailItem)

With otlmail
.Body = "Hi " & Cells(i, 1).Value _
& vbNewLine & vbNewLine & _
"Please provide the BS Recon for attached global account details for " & Range("B2") & " of " & Range("B1")
.To = Cells(i, 2).Value
.CC = Cells(i, 3).Value
.Subject = Range("B3") & ":" & Cells(i, 4).Value & " BS RECON BACKUP " & Range("B1")
.Attachments.Add Cells(i, 5).Value
.Display

End With
'MsgBox "Selected Item Sent", vbOKOnly


' ElseIf Cells(i, 6).Value = "NO" Then
' MsgBox "Mail Not Required", vbOKOnly
' Exit Sub
End If
Next i
Set Otl = Nothing
Set otlmail = Nothing

MsgBox "DONE", vbOKOnly
'MsgBox "Mail Has Been Sent To Respective Person Along With Files", vbOKOnly

End Sub

FYI - I have accessed all related References.
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
when you step through with f8, where is the error
 
Upvote 0
i already tried but there is no error. it is not working in my system only. some other systems means it is working properly.
 
Upvote 0
too many unknowns for me to guess an answer
 
Upvote 0
where you have confusions

see this code for open outlook but outlook is not opened--->
Dim Otl As Outlook.Application
Set Otl = New Outlook.Application
 
Upvote 0
My code is looking perfect it worked but I don't know what's happened to my outlook suddenly outlook not open while I run the code only ^done^ massage will come....
 
Upvote 0
If you are seeing the 'Done' message it is likely the email has been sent. Check by sending to one of your addresses.

With Outlook closed step through your code using F8 do you see an Outlook icon appear on the taskbar when the Outlook instance is created?
If so it is working. It will close when the message is sent.

You may have set 'hidden when minimised'. Look into that.
 
Upvote 0
Here The Problem is i click the check box in VBA reference -Microsoft Outlook 16.0 Object Library but while i run the code the outlook new mail box is not opened automatically,
not only this macro i have some other code that one also same issue i faced now,

i think the problem is in my outlook application.

can you please help me on that ?
 
Upvote 0
do a full restart before troubleshooting further
 
Upvote 0
Can anyone help me on this code why its not working but error not showing once i run the code outlook mail box not opened,only message box showing " DONE"
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Sub SEND_EMAIL_WITH()


Sheet1.Activate
Dim Otlapp As Object
Set Otlapp = New Outlook.Application
Dim otlmail As Outlook.MailItem

Dim i As Long

For i = 2 To Range("A150").End(xlUp).Row
If Cells(i, 6).Value = "yes" Then

Set otlmail = Otl.CreateItem(olMailItem)
On Error Resume Next
With otlmail
.Body = "Hi " & Cells(i, 1).Value _
& vbNewLine & vbNewLine & _
"Please provide the BS Recon for attached global account details for " & Range("B2") & " of " & Range("B1")
.To = Cells(i, 2).Value
.CC = Cells(i, 3).Value
.Subject = Range("B3") & ":" & Cells(i, 4).Value & " BS RECON BACKUP " & Range("B1")
.Attachments.Add Cells(i, 5).Value
.Display

End With
End If
Next i


Set otlmail = Nothing
Set Otlapp = Nothing

MsgBox "DONE", vbOKOnly
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,918
Messages
6,122,241
Members
449,075
Latest member
staticfluids

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top