0

I am trying to be able to forward an email using Ampscript. I am able to retrieve the JobID for the previous send. I don't know if one can access a dataview using Ampscript for this. I was wondering if there is a way to use the JobID for the send to get the EmailID using Ampscript?

The plan is to use the EmailID in a triggered send later on.

2

You can gather the email name from emailname_ and the email id via _emailid personalization string. This will directly pull in the values from the current email and will not require any lookups or data manipulation.

e.g.

%%[
  var emailid = _emailid
  var emailname = emailname_
]%%

or <p>This is the name of the email: %%emailname_%%</p>
or <p>This is the id of the email: %%_emailid%%</p>

If it is after the email was sent, I would just use a SQL Query to the Job Data View which will provide the emailid.

E.g.

SELECT jobid, emailid
FROM [_Job]
WHERE jobid = 8675309

As a last resort, you CAN use ampscript to gather it via a lookup to the Job Dataview, but I do not recommend it as this will greatly increase processing time and can lead to errors or time outs on your email.

E.g.

%%[
  SET @emailidRows = LOOKUPROWS("_Job", "JobID", 8675309 )
  SET @Row = ROW(@emailidRows,1)
  SET @emailid = FIELD(@Row,"EmailID")
]%%
<br>
EmailID: %%=v(@emailid)=%%
<br>

Will output: EmailID: 123456

  • 1
    Thank you @Gortonington for your detailed response. May I confirm that it is best to not use the LOOKUPROWS for all data views or just data views with several entries like the Job data view? – Quaser8000 Aug 19 at 14:15
  • For any data views. Job DV is not too bad as its usually lower volume, but DV like Open or Sent or Clicks are very bad news due to the high volume of data inside of them. – Gortonington Aug 19 at 14:28
  • Thank you for your help with this. I have managed to get both the email name and email id. Good to know about the data views and potential volumes. – Quaser8000 Aug 19 at 14:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.