LoginSignup
1
0

More than 5 years have passed since last update.

SendGridのメール履歴で特定のタイトルに一致するメールを受信しているユーザーのメールアドレスを取得する

Last updated at Posted at 2019-02-06

背景

システム的に一部ユーザーに誤送信をしてしまいました。そして誰に送ったかはシステム上では記録しておらず誰に送ったかを知る必要がありました。
メールサーバーにはSendGridを使用しており、APIには送ったメールをタイトルで検索などができなさそうでした。

(SendGridのActivityFeedに subject がありましたが検索できず・・)

そこでjsを使ってconsole.logに上げたのでそのコードをメモ。

コード

function logEmails() {
  var subject = 'このタイトルを検索したい'
  document.querySelectorAll('td.col-5').forEach(function(tag, index) {
    if(tag.querySelectorAll('span.subject')[0].textContent == subject) {
      console.log(tag.querySelectorAll('span.email')[0].textContent);
    }
  })
};

setInterval(function() {
  document.querySelectorAll('a.pagination-next')[0].click()
  logEmails();
}, 3000)

あとがき

多分、発火タイミングはもっと厳密にやるべき。
renderingが遅れたら多分検知できなくなる

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0