Jump to content
User_1994

Sending email via _INetSmtpMail() Function

Recommended Posts

Hi all,

I am trying to send a simple test email using the _INetSmtpMail() function but I am receiving "Mail failed with error code 50" message.

 

Here is my code below (copied from the autoit page and modified variables):

#include <Inet.au3>
#include <MsgBoxConstants.au3>

Local $s_SmtpServer = "outlook.office365.com"
Local $s_FromName = "[My name]"
Local $s_FromAddress = "[my office 365 email]" 
Local $s_ToAddress = "[my office 365 email]"
Local $s_Subject = "My Test UDF"
Local $as_Body[2]
$as_Body[0] = "Testing the new email udf"
$as_Body[1] = "Second Line"
Local $iResponse = _INetSmtpMail($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $as_Body)
Local $iErr = @error
If $iResponse = 1 Then
    MsgBox($MB_SYSTEMMODAL, "Success!", "Mail sent")
Else
    MsgBox($MB_SYSTEMMODAL, "Error!", "Mail failed with error code " & $iErr)
EndIf

I changed the name/email addresses for privacy.

 

Thanks for any help.

Share this post


Link to post
Share on other sites

@User_1994 Did you get it to work with CDO?
I looked everywhere and can find a good working solution to use CDO with office 365 mail (I only get CDO to work with port 25).
I made a Autoit wrapper for the Swith Mail (Swith Mail is small standalone exe) and that worked perfect for me.
 

 

Share this post


Link to post
Share on other sites

The linked UDF does work fine for me with O356. ;)
I use these settings:

$SmtpServer = "smtp.office365.com"              ; address for the smtp-server to use - REQUIRED
$FromName = "Jos"                      ; name from who the email was sent
$FromAddress = "jos.....@outlook.com" ;  address from where the mail should come
$ToAddress = "jos.....@yahoo.com"   ; destination address of the email - REQUIRED
$Subject = "Test O365 message"                   ; subject from the email - can be anything you want it to be
$Body = " test email"                             ; the messagebody from the mail - can be left blank but then you get a blank mail
$AttachFiles = ""                       ; the file you want to attach- leave blank if not needed
$CcAddress = ""       ; address for cc - leave blank if not needed
$Importance = "Normal"                  ; Send message priority: "High", "Normal", "Low"
$BccAddress = ""                            ; address for bcc - leave blank if not needed
$Username = "jos......@outlook.com"                    ; username for the account used from where the mail gets sent - REQUIRED
$Password = "?????????"                  ; password for the account used from where the mail gets sent - REQUIRED
$SmtpServer = "smtp.office365.com"              ; address for the smtp-server to use - REQUIRED
$IPPort=25                             ; port used for sending the mail
$ssl=1                                 ; enables/disables secure socket layer sending - put to 1 if using httpS

Jos 


SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...