Ask a Question

SendEmail using Gmail

SOLVED
joaosaidel
Occasional Contributor

SendEmail using Gmail

Hi guys, i need your help, i from Brazil, i'm trying to use SendEmail with Gmail, but i cann't. I tried to using two ways,

(I've tried everything, I don't know what else to do)

The simple way

 

procedure Test;
begin
if SendMail('testcompletesuprema@gmail.com', 'smtp.gmail.com', 'João Saidel', 'jp2822@gmail.com', 'Notification', 'Hello Clare, Your application is nice.', 'C:\File1.txt', 'C:\File1.txt') then
Log.Message('Mail was sent')
else
Log.Warning('Mail was not sent');
end;

 

and

 

function SendEmail(mFrom, mTo, mSubject, mBody, mAttach);
var i, schema, mConfig, mMessage;
begin
  try
    schema := 'http://schemas.microsoft.com/cdo/configuration/';
    mConfig := Sys.OleObject('CDO.Configuration');
    mConfig.Fields.Item(schema + 'sendusing') := 2; // cdoSendUsingPort
    mConfig.Fields.Item(schema + 'smtpusessl') := true; // Use SSL
     mConfig.Fields.Item(schema + 'smtpserver') := '"smtp.gmail.com';
     mConfig.Fields.Item(schema + 'smtpserverport') := 465;

   
    mConfig.Fields.Item(schema + 'smtpauthenticate') := 1; // Authentication mechanism
    mConfig.Fields.Item(schema + 'sendusername') := 'testcompletesuprema@gmail.com'; // User name (if needed)
    mConfig.Fields.Item(schema + 'sendpassword') := ******; // User password (if needed)
    mConfig.Fields.Item(schema + 'smtpconnectiontimeout') := 60; // User password (if needed)
    mConfig.Fields.Update;

    mMessage := Sys.OleObject('CDO.Message');
    mMessage.Configuration := mConfig;
    mMessage.From := mFrom;
    mMessage.To := mTo;
    mMessage.Subject := mSubject;
    mMessage.HTMLBody := mBody;
     
    aqString.ListSeparator := ',';
    for i := 0 to aqString.GetListLength(mAttach) - 1 do
      mMessage.AddAttachment(aqString.GetListItem(mAttach, i));

    mMessage.Send;
 
    //Log.Message('Message to <' + mTo + '> was successfully sent');
    //Result := True;
  //except
    //Log.Error('Email cannot be sent', ExceptionMessag);
    //Result := False;
 // end;
end;

procedure MainTest;
begin
  if SendEmail('testcompletesuprema@gmail.com', 'jp29822@gmail.com', 'Subject',
             'Message body', 'c:\File1.txt') then
    log.Message(' Message was sent')
  else
    Log.Warning('Message was not sent');
end;

1 ACCEPTED SOLUTION

Accepted Solutions
Marsha_R
Community Hero

Re: SendEmail using Gmail

See if this helps

https://support.smartbear.com/testcomplete/docs/testing-with/log/working-with/sending-via-email/abou...


Marsha_R
[Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame

View solution in original post

7 REPLIES 7
joaosaidel
Occasional Contributor

Re: SendEmail using Gmail

The simple way, i have this erro, '

Socket Error # 10060
Connection timed out.

'

joaosaidel
Occasional Contributor

Re: SendEmail using Gmail

second way, i have this erro, '

CDO.Message.1

Transport connection to server failed

'

 
Marsha_R
Community Hero

Re: SendEmail using Gmail

Are you able to access Gmail manually on the TestComplete machine and send a message to the FromAddress that you are using in the test?


Marsha_R
[Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
joaosaidel
Occasional Contributor

Re: SendEmail using Gmail

I can't, I'm reviewing sendemail parameters

joaosaidel
Occasional Contributor

Re: SendEmail using Gmail

I managed to send the email. Is there a way to view the logs via email?

Marsha_R
Community Hero

Re: SendEmail using Gmail

See if this helps

https://support.smartbear.com/testcomplete/docs/testing-with/log/working-with/sending-via-email/abou...


Marsha_R
[Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame

View solution in original post

sonya_m
Community Manager

Re: SendEmail using Gmail

Thank you for providing the help article, Marsha!

 

Hi @joaosaidel! Did it answer your question? 


Sonya Mihaljova
Community and Education Specialist

cancel
Showing results for 
Search instead for 
Did you mean: