Send Mail using windows 10 not outlook

nehpets12

Active Member
Joined
Feb 22, 2002
Messages
453
Hi Is it possible to send mail using windows 10 not outlook

What code has to change from outlook to windows 10

I have vba code that works for outlook but not windows 10

Thanks in advance
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
the OP does not want to use Outlook.

Win10 Mail does not have an object model that supports VBA afaik

Ron de Bruin does have this which may help: Sending mail from Excel with CDO

i ended up using a (paid) 3rd party .dll which suits my purpose
 
Upvote 0

Set Reference to Microsoft Office Library​

We need to send emails from Outlook. Since Outlook is an outside object first thing we need to do is to set the object reference to “Microsoft Outlook 16.0 Object Library”.
  1. In VBA, Go to Tools > References.
  2. Now we will see the object reference library. In this window, we need to set the reference to “Microsoft Outlook 16.0 Object Library.”
  3. After setting the object reference, click on, Ok.
    Now we can access Outlook object in VBA coding.



VBA Code:
Dim EmailApp As Outlook.Application
Dim Source As String
Set EmailApp = New Outlook.Application

Dim EmailItem As Outlook.MailItem
Set EmailItem = EmailApp.CreateItem(olMailItem)

EmailItem.To = "Hi@gmail.com"
EmailItem.CC = "hello@gmail.com"
EmailItem.BCC = "hhhh@gmail.com"
EmailItem.Subject = "Test Email From Excel VBA"
EmailItem.HTMLBody = "Hi," & vbNewLine & vbNewLine & "This is my first email from Excel" & _
vbNewLine & vbNewLine & _
"Regards," & vbNewLine & _
"VBA Coder"
Source = ThisWorkbook.FullName
EmailItem.Attachments.Add Source

EmailItem.Send

End Sub


Now you just need to edit the code according to your needs.
Hope this helps You Out.
 
Upvote 0
You can use the built-in Mail app if you want to send mail in Windows 10 without Outlook. However, remember that the code you wrote for Outlook may need to be modified to work with the Mail app. The API and syntax may differ between the two platforms.

I recommend looking at the documentation and resources related to the Mail app for Windows 10 to see what changes need to be made to the code. You may need to adapt the VBA code or switch to another programming language depending on the capabilities of the Mail app.
 
Upvote 0
Here is a method using CDO & your gmail email account :

VBA Code:
Option Explicit

Sub Sendmail()
  Dim Mail As New Message, Config As Configuration
  Dim subject As String, mailbody As String, i As Long, lr As Long
 
  ThisWorkbook.Sheets("Sheet1").Activate
  subject = Range("H2").Value
  lr = Range("C" & Rows.Count).End(xlUp).Row
  For i = 2 To lr
    Set Config = Mail.Configuration
    Config(cdoSendUsingMethod) = cdoSendUsingPort
    Config(cdoSMTPServer) = "smtp.gmail.com"
    Config(cdoSMTPServerPort) = 465
    Config(cdoSMTPAuthenticate) = cdoBasic
    Config(cdoSMTPUseSSL) = True
    Config(cdoSendUserName) = "Your GMail Account Name Here"
    Config(cdoSendPassword) = "Your GMail Account Password Here"
    Config.Fields.Update


    mailbody = "Dear " & Range("c" & i).Value & "," & Range("h3").Value & vbCrLf & vbCrLf
    Mail.To = Range("D" & i).Value
    Mail.cc = Range("E" & i).Value
    Mail.From = Config(cdoSendUserName)
    Mail.subject = Range("c" & i).Value & " " & subject
    Mail.HTMLBody = mailbody
    'Mail.AddAttachment Range("F" & i).Value
    On Error Resume Next
    Mail.Send
    On Error GoTo 0
    Set Config = Nothing
    Set Mail = Nothing
  Next i
  If Err.Number <> 0 Then
    MsgBox Err.Description, vbCritical, "There was an error"
  Else
    MsgBox "Your email has been send", vbInformation, "Sent"
  End If
End Sub
 
Upvote 0
You can use the built-in Mail app if you want to send mail in Windows 10 without Outlook. However, remember that the code you wrote for Outlook may need to be modified to work with the Mail app. The API and syntax may differ between the two platforms. I recommend looking at the documentation and resources related to the Mail app for Windows 10 to see what changes need to be made to the code. You may need to adapt the VBA code or switch to another programming language depending on the capabilities of the Mail app. To get full access to all the operating system's features, buying cheap windows keys is recommended. Good luck, and I hope you find a solution.
thanks for the solution, Logit!
 
Upvote 0

Forum statistics

Threads
1,215,059
Messages
6,122,918
Members
449,093
Latest member
dbomb1414

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