Failed to Create Attachment
I have tried to create an attachmenets but I got the following exception:
StackTrace = " at TDAPIOLELib.IAttachment3.Post()\r\n at ...
public static void uploadNewUrlAttachment1(Test test, string hyperlink)
FileInfo attachmentTemporaryFile = CreateUrlFile(hyperlink);
if (attachmentTemporaryFile != null)
AttachmentFactory attFactory = (AttachmentFactory)test.Attachments;
Attachment attachmentObject = (Attachment)attFactory.AddItem(System.DBNull.Value);
attachmentObject.Type = (int)tagTDAPI_ATTACH_TYPE.TDATT_FILE;
attachmentObject.FileName = attachmentTemporaryFile.FullName;
attachmentObject.Description = hyperlink;
catch (Exception e)
this code works without any problem with Quality Center 10.0
I have Windows 7
could you help me?
Please verify that in VB works, it could be code logic issue or Com problem (Bug), please let me know your results.
Sample in vb
Sub Attachment_Load(Debug, CurrentTestSet, CurrentTest, CurrentRun) ' Workflow script On Error Resume Next TDOutput.Clear Set BugFact = TDConnection.BugFactory Set theBug = BugFact.Item(21) Set AttachFact = theBug.Attachments Set theAttachmentsCollection = AttachFact.NewList("") Set theAttachment = theAttachmentsCollection.Item(1) 'This works in VB, but not in VBScript: 'theAttachment.Load True, LoadPath 'In VBScript, use this: theAttachment.Load True, "" tdoutput.Print theAttachment.FileName ' To get the path in VBScript, extract it from ' the filename: theFileName = theAttachment.FileName tdoutput.Print theFileName thePath = Left(theFileName, InstrRev(theFileName, "\")-1) tdoutput.Print thePath ' handle run-time errors If Err.Number <> 0 Then TDOutput.Print "Run-time error [" & Err.Number & "] : " & Err.Description ' update execution status in "Test" mode If Not Debug Then CurrentRun.Status = "Failed" CurrentTest.Status = "Failed" End If End If End Sub
If you find this or any post resolves your issue, please be sure to mark it as an accepted solution"