I have tried with below AMPscript code to fetch all the email names with the subject line from our account. However, the below code is fetching only classic content emails and it's not pulling the content builder email.
Salesforce support also confirmed that AMPscript is pulling only classic emails. It does not include Content Builder emails.
Kindly let me know if there is any other way to fetch all the emails including content builder email.
%%[
SET @rr = CreateObject("RetrieveRequest")
SetObjectProperty(@rr, "ObjectType", "Email")
AddObjectArrayItem(@rr,"Properties","Name")
AddObjectArrayItem(@rr,"Properties","Subject")
SET @rows = InvokeRetrieve(@rr)
RowCount(@rows)
FOR @i = 1 to RowCount(@rows) DO
SET @row = Row(@rows ,@i)
SET @emailName = Field(@row ,'Name')
SET @emailSubject = Field(@row ,'Subject')
outputline(concat("<br>EmailName:", @emailName))
outputline(concat("<br>EmailSubject:", @emailSubject))
InsertData("CheckEmail",'EmailName', @emailName,"EmailSubject", @emailSubject)
NEXT @i
]%%
EDIT
This is current code based on Gortonington's answer. I receive an empty response though:
var restBase = "url";
var queryStr = '?$page=1&$pagesize=100&$orderBy=name asc&$filter=data.email.legacy.legacyType=email&$fields=name,views';
var authToken = "genertaed";
var Result = getCBEmails(restBase,queryStr,authToken)
Write("<br/><br/>Results: " + Result)
function getCBEmails(restBase,queryStr,authToken) {
var headerNames = ["Accept", "Authorization"];
var headerValues = ["application/json", "Bearer "+authToken];
var url = restBase + '/asset/v1/content/assets' + queryStr;
var response = HTTP.Get(url, headerNames, headerValues);
return response;
}