Forum Discussion
Hi JBSoccerbrit,
The question about adding attachments to the message have already been discussed several times. Refer to the following topics for details:
http://community.smartbear.com/t5/Functional-Web-Testing/Sending-EMail-Through-Script/td-p/58550
- JBSoccerbrit9 years agoContributor
Hi Tanya unfortunately neither of the links you provided really answer my question, or not to the point of where I understand how they answer my question specifically.
I'm looking for more of a guide.
Example;
1) select call object method
2) pick slpacker
- What selections should be made here to grab the log files and put them in the correct extension type?
3) select run code snippet
- I'm assuming here I attempt to use one of the 3 methods available to send the email (SendMail which is built in, CDO or outlook).
Thanks,- TanyaYatskovska9 years agoSmartBear Alumni (Retired)
Hi JBSoccerbrit,
The community discussions I mentioned are talking about the ways on how to add attachments to email messages. sdruker uses the following code for this:
Public Function SendEmail(mFrom, mTo, mSubject, mBody, mAttachment) Dim i, schema, mConfig, mMessage, mAttach Err.Clear On Error Resume Next schema = "http://schemas.microsoft.com/cdo/configuration/" Set mConfig = Sys.OleObject("CDO.Configuration") mConfig.Fields.Item(schema + "sendusing") = 2 ' cdoSendUsingPort mConfig.Fields.Item(schema + "smtpserver") = "SMTP server" ' 'mConfig.Fields.Item(schema + "smtpserver") = "ServerName" ' SMTP server mConfig.Fields.Item(schema + "smtpserverport") = 25 ' Port number mConfig.Fields.Item(schema + "smtpauthenticate") = 1 ' Authentication mechanism ' mConfig.Fields.Item(schema + "sendusername") = "" ' User name (if needed) ' mConfig.Fields.Item(schema + "sendpassword") = "" ' User password (if needed) mConfig.Fields.Update Set mMessage = Sys.OleObject("CDO.Message") mMessage.Configuration = mConfig mMessage.MimeFormatted=true mMessage.From = mFrom mMessage.To = mTo mMessage.Subject = mSubject mMessage.HTMLBody = mBody aqString.ListSeparator = "," For i = 0 To aqString.GetListLength(mAttachment) - 1 mMessage.AddAttachment aqString.GetListItem(mAttachment, i) mMessage.Attachments.Item(1).ContentMediaType="application/octet-stream" Next mMessage.Send() If Err.Number > 0 Then Log.Error "E-mail cannot be sent", Err.Description SendEMail = False Else Log.Message "Message to <" + mTo + "> was successfully sent" SendEMail = True End If End Function
If you want to attach the current test log, you will need to save it first. For this, you can use the Log.SaveResultsAs method. Please refer to the "SaveResultsAs method" article ( http://support.smartbear.com/viewarticle/75301/ ) for more information.
Does it clarify the situation?
Related Content
- 3 years agoEgg