Sending EMail Through Script
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sending EMail Through Script
Hi,
Below is the script written to send an email through script, but I'm not getting any email... any suggestions here please?
Sub MainTest
If SendEmail("anil.yadrami@in4velocity.com", "anil.yadrami@in4velocity.com", "Subject", _
"Message body", "E:\Anil-Backup\Test Complete\Projects_Old\In4Suite Project\TC_Command_Line.txt") Then
' Message was sent
Log.Message "sent"
Else
' Message was not sent
Log.Message "not sent"
End If
End Sub
'This function is called above
Function SendEmail(mFrom, mTo, mSubject, mBody, mAttachment)
Err.Clear
On Error Resume Next
schema = "http://webmail.in4velocity.com/"
Set mConfig = Sys.OleObject("CDO.Configuration")
' mConfig.Fields.Item(schema + "sendusing") = 587 ' cdoSendUsingPort 'commented this, dont know what exactly this do
mConfig.Fields.Item(schema + "smtpserver") = "smtp.gmail.com" ' SMTP server
mConfig.Fields.Item(schema + "smtpserverport") = 587 ' Port number
mConfig.Fields.Item(schema + "sendusername") = "anil" ' User name (if needed)
mConfig.Fields.Item(schema + "sendpassword") = "Pwd123456" ' User password (if needed)
mConfig.Fields.Update()
Set mMessage = Sys.OleObject("CDO.Message")
mMessage.Configuration = mConfig
mMessage.From = "anil.yadrami@in4velocity.com"
mMessage.To = "anil.yadrami@in4velocity.com"
mMessage.Subject = "Automation: Testing"
mMessage.HTMLBody = "Email Received"
aqString.ListSeparator = ","
For i = 0 To aqString.GetListLength(mAttachment) - 1
mMessage.AddAttachment aqString.GetListItem(mAttachment, i)
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
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
There is nothing displayed in Additional Details section in the log. The script is passing but I dont get any email. I've few doubts, please let me know...
1. Do I need to login to my email account through IE and keep it open?
2. In the script sendusing is = 2 "mConfig.Fields.Item(schema + "sendusing") = 2 ' cdoSendUsingPort" I'm using this line as it is, do I need to change it?
3. We are using gmail for office internal email, the link will be http://www.webmail.in4velocity.com, do I need to mention this anywhere in the script? Our gmail is configured to MS-outlook, do you think of any other settings?
4. In SendEmail, I'm giving "c:\Hello.txt", should this file be of any format or for testing purpose I can pass any file as below...?
If SendEmail("anil.yadrami@in4velocity.com", "anil.yadrami@in4velocity.com", "Automation: Script Email", "Automation Message body", "c:\Hello.txt") Then
SendEmail("anil.yadrami@in4velocity.com", "anil.yadrami@in4velocity.com", "Automation: Script Email", "Automation Message body", "c:\Hello.txt")
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Do I need to login to my email account through IE and keep it open?
No, this isn't needed.
In the script sendusing is = 2 "mConfig.Fields.Item(schema + "sendusing") = 2 ' cdoSendUsingPort" I'm using this line as it is, do I need to change it?
The sendusing field specifies the method used to send messages. "2" means that the message should be sent via the network. Go through this MSDN section to get detailed information on configuring the CDO scheme.
should this file be of any format
According to the MSDN description of the CDO.Message.AddAttachment method, you can add any type of attachment to a message.
do I need to mention this anywhere in the script
No, you needn't.
A few more things to try:
* Use port 25 or 465 (not 587).
* If your Google Apps domain uses 2-step verification, you may need to generate an application-specific password for your account and use that password in your script instead of the Google Apps account password.
Finally, I'd like to note that the CDO (Collaboration Data Objects) library used in your script is developed and maintained by Microsoft, and we don't provide technical support for third-party scripting objects. So, I recommend troubleshooting this issue with your system administrator and a Google Apps administrator, on MSDN Forums or Stack Overflow. You'll more likely get an answer there. In addition to that, you can find troubleshooting tips using Google search for cdo "google apps".
Good luck!
Ann
Any views or opinions expressed do not necessarily represent those of SmartBear Software.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi, Can someone help me in reading or verifying the received emails using Collaboration Data Object (CDO).
Thank you,
Srini

- « Previous
-
- 1
- 2
- Next »
- « Previous
-
- 1
- 2
- Next »