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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Send e-mail using Outlook.com from Access 1

Status
Not open for further replies.

48Highlander

Technical User
Feb 8, 2004
119
CA
I have upgraded to Win 10 and I have no e-mail client installed. How do I send e-mails using the Windows 10 mail app from MS Access?

Everything I have found is based on sending mail through a desktop client or through web mail such as G-Mail. Win 10 mail does not appear to be an installed app so I assume it is a web based app.

Does anybody have VBA code to send mail through Win 10 mail? Or the settings to use?

Bill J
 
This is what I use to send e-mails from my code, but I have not tried it in Win 10 yet.
You just need to set your cdoSMTPServer and pass some parameters into this Sub.


Code:
[green]
'''Add Referebce to: Microsoft CDO For Windows 2000 Library
[/green]
Public Sub SendAMessage(strFrom As String, strTo As String, _
    strCC As String, strSubject As String, strTextBody As String, _
    Optional strBcc As String, Optional strAttachDoc As String, _
    Optional blnHighPriority As Boolean = False)

Dim objMessage As CDO.Message

On Error GoTo MyErrorHadler

Set objMessage = New CDO.Message

With objMessage
    .From = strFrom
    .To = strTo
    If Len(Trim$(strCC)) > 0 Then
        .CC = strCC
    End If
    If Len(strBcc) > 0 Then
        .BCC = strBcc
    End If[green]
    ''' On behalf of
    '.Sender = "Bill.Gates@msn.com"[/green]

    If blnHighPriority Then
       With .Fields[green]
           ' for Outlook:[/green]
           .Item(cdoImportance) = cdoHigh
           .Item(cdoPriority) = cdoPriorityUrgent
    [green]
           ' for Outlook Express:
           '.Item("urn:schemas:mailheader:X-Priority") = 1[/green]
    
           .Update
       End With
    End If

    .Subject = strSubject

    If InStr(UCase(strTextBody), "<HTML>") Or InStr(UCase(strTextBody), "</HTML>") Then
        .HTMLBody = strTextBody
    Else
        .TextBody = strTextBody
    End If
    
    If Len(strAttachDoc) > 0 Then
        .AddAttachment strAttachDoc
    End If
    
    With .Configuration.Fields
        .Item(CDO.cdoSMTPServer) = [red]"YOUR.SMTP.SERVER.LAN"[/red]
        .Item(CDO.cdoSMTPServerPort) = 25
        .Item(CDO.cdoSendUsingMethod) = CDO.cdoSendUsingPort
        .Item(cdoSMTPConnectionTimeout) = 10
        .Update
    End With
    .Send
End With

Set objMessage = Nothing

Exit Sub
MyErrorHadler:
[green]
'' Do something here in case of an error
[/green]
Resume Next

End Sub

You may also want to contact your e-mail admin to allow your application to send e-mails this way. (because you can send a LOT of e-mails this way, i.e. SPAM)

Have fun.

---- Andy

A bus station is where a bus stops. A train station is where a train stops. On my desk, I have a work station.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top