Highlighted
Visitor.
368 views

TDConnection.Sendmail how send a chart from excel?

Jump to solution

Good day, Community.

I don´t know so much about ALM, but in my work i must send a chart generated in excel by email. for this,  i must use a macro and ALM from Excel. Already i can send an email from excel, but i don´t know how attachment this chart. somebody can help me, i appreciate so much. Thanks

this is my code:

 

Sub Email()

Set QCConnection = CreateObject("TDApiOle80.TDConnection")
QCConnection.InitConnectionEx "http://xxxxxxxxxx/qcbin/"
QCConnection.Login "xxxxxxxx", "xxxxxxxxxxx"
QCConnection.Connect "LATAM", "xxxxxxxxx"
Set ConnectToQC = QCConnection
If (QCConnection.LoggedIn = True) Then
MsgBox "QC Ok"

QCConnection.SendMail "xxxxxxxxxxxxxxxxxxx@xxx.com", "", "email automatico"
Else
MsgBox "Invalid- Id or Password"
Exit Sub

End If

End Sub

 

 

Labels (1)
0 Likes
1 Solution

Accepted Solutions
Highlighted
Micro Focus Expert
Micro Focus Expert

It's possible but it's too difficult. 

At first, you need to save the Chart to a local file with Excel's capability.

Then, you need to upload this file as an attachment to an entity. (Defect, Test, Requirement. etc.)

At last, pass an array of attachment.ServerFileName as fifth parameter to SendMail 

It's not an easy thing to do this, but everything is possible. 😀

View solution in original post

3 Replies
Highlighted
Micro Focus Expert
Micro Focus Expert

It's possible but it's too difficult. 

At first, you need to save the Chart to a local file with Excel's capability.

Then, you need to upload this file as an attachment to an entity. (Defect, Test, Requirement. etc.)

At last, pass an array of attachment.ServerFileName as fifth parameter to SendMail 

It's not an easy thing to do this, but everything is possible. 😀

View solution in original post

Highlighted
Respected Contributor.. Respected Contributor..
Respected Contributor..

Hi there, 

Wouldnt it be easier to use Excel VBA to export the chart into a Gift for example, then use Outlook HTML  capabilities to attach the image as body and email it?. 

Something like this : http://www.learnexcelmacro.com/wp/2012/08/mail-chart-as-image-from-outlook-vba-code/

0 Likes
Highlighted
Super Contributor.. Super Contributor..
Super Contributor..

Hi

This function will add the attachment to the Test Run and send mail with the attachment. Hope this help.

Public Sub SendMailWithResult(strMailTo, strSubject, strMessage, strAttachement)
        On Error resume next
        Dim QCConnection 
        Dim objCurrentTest
        Dim objCurrentTestSet
        Dim strPictureName
        Dim objCurrentRun
        Dim attachFact
        Dim theAttachment
    	Dim AttachmentList(0)
        Dim ExStrg 


		'Check if UFT connect to ALM, it must be true for send mail
        If QCUtil.IsConnected then
                Set QCConnection = QCUtil.QCConnection 
                Set objCurrentTest  = QCUtil.CurrentTest
                Set objCurrentTestSet = QCUtil.CurrentTestSet
                Set objCurrentRun = QCUtil.CurrentRun

                strTestSetURL = "td://<<project.domain.ALM IP>:8080/qcbin/TestLabModule-000000003649890581?EntityType=ITestSet&EntityID=" & objCurrentTestSet.ID

	            Set attachFact = objCurrentRun.Attachments
	            Set theAttachment = attachFact.AddItem(Replace(UCase(strAttachement), "C:\TEMP\", ""))
	            theAttachment.Description = "Test Result"
	            theAttachment.Post
				Set ExStrg = theAttachment.AttachmentStorage
	            ExStrg.ClientPath = "C:\Temp\"
	            ExStrg.Save Replace(UCase(strAttachement), "C:\TEMP\", ""), True
	
	            'msgbox theAttachment.ServerFileName
				AttachmentList(0) = theAttachment.ServerFileName
	            'msgbox "AttachmentList(0)=" & AttachmentList(0)
	            
	            strSender = "admin@alm.com"

				If Reporter.RunStatus = micPass Then
                        strSubject = objCurrentTestSet.Name & " - " & strSubject & " Passed"
                        strMessage = "<font face=""verdana"">Test Set:<a href=""" & strTestSetURL & """>" & objCurrentTestSet.Name & "</a> Finished!<br>Result:<b><font color=""green"">Passed</b></font><br><br>" & strMessage & "</font>"
                        QCConnection.SendMail strMailTo, strSender, strSubject, strMessage, AttachmentList
                Else
                        strSubject = objCurrentTestSet.Name & " - " & strSubject & " Failed"
                        strMessage = "<font face=""verdana"">Test Set:<a href=""" & strTestSetURL & """>" & objCurrentTestSet.Name & "</a> Finished!<br>Result:<b><font color=""red"">Failed</b></font><br><br>" & strMessage & "</font>"
                        QCConnection.SendMail strMailTo, strSender, strSubject, strMessage, AttachmentList
                End If

                Set ExStrg = Nothing
                Set attachFact = Nothing
                Set theAttachment = Nothing
                Set objCurrentRun = Nothing
                Set objCurrentTestSet = Nothing
                Set objCurrentTest  = Nothing
                Set QCConnection = Nothing          
        End If
        On error goto 0
End Sub

 

The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.