Attachment in the email when the state changes

I am looking for a solution where, when there is a state change, the VBScript sends an email to an email address defined in a metadata field, and the email should have an attachment of one file (e.g., Excel) attached to a multi-type document.

I've made it this far — I already receive the email, now I just need to attach the file associated with the document to the email.

Dim emailAdd
emailAdd = PropertyValues.SearchForProperty(1105).Value.DisplayValue


Dim oEmailMessage: Set oEmailMessage = CreateObject("CDO.Message")
oEmailMessage.To = emailAdd
oEmailMessage.From = "....."
oEmailMessage.Subject = "Dokumentum értesítés"
oEmailMessage.TextBody = "Csatoltan küldjük a dokumentumot."


Dim oConf: Set oConf = oEmailMessage.Configuration
oConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
oConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") ="ip_adress..."
oConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 587
oConf.Fields.Update

oEmailMessage.Send

Parents
  • You need to cycle through files with "for each" and download the files and then attach

    Vault.ObjectFileOperations.DownloadFile oObjectFile.ID, oObjectFile.Version, Path
    MyEmail.AddAttachment Path
    for path, you can set a path like 
    Path = "E:\TempFiles\" + oObjectFile.GetNameForFileSystem()
  • I don't understand what you're saying, could you please explain in more detail which part of my code I should insert it into?

    Unfortunately, I'm not a great VBScript programmer, but I was able to put together the basic email sending without attachments.

  • 		For Each oObjectFile In pObjectFiles
    			'Construct the target path for downloading the file.
    			'err.raise mfscriptcancel, pDocName2
    			Dim szTargetPath : szTargetPath = "E:\TempFiles\" + oObjectFile.GetNameForFileSystem()
    			Dim DosyaAd : DosyaAd = oObjectFile.GetNameForFileSystem()
    
                IF Instr(1, DosyaAd,".pdf",1) Then
                    Vault.ObjectFileOperations.DownloadFile oObjectFile.ID, oObjectFile.Version, szTargetPath
                    'Add File
                    oEmailMessage.AddAttachment szTargetPath
                    'Add File To AllPaths
                    allPath = allPath + szTargetPath + ","
                END IF
    		Next

    Ok, try this then. You still need to get "oObjectFile" to be defined

Reply
  • 		For Each oObjectFile In pObjectFiles
    			'Construct the target path for downloading the file.
    			'err.raise mfscriptcancel, pDocName2
    			Dim szTargetPath : szTargetPath = "E:\TempFiles\" + oObjectFile.GetNameForFileSystem()
    			Dim DosyaAd : DosyaAd = oObjectFile.GetNameForFileSystem()
    
                IF Instr(1, DosyaAd,".pdf",1) Then
                    Vault.ObjectFileOperations.DownloadFile oObjectFile.ID, oObjectFile.Version, szTargetPath
                    'Add File
                    oEmailMessage.AddAttachment szTargetPath
                    'Add File To AllPaths
                    allPath = allPath + szTargetPath + ","
                END IF
    		Next

    Ok, try this then. You still need to get "oObjectFile" to be defined

Children
No Data