added support for document tracking

pull/535/head
ekleintop 2017-02-10 12:58:59 -05:00 committed by GitHub
parent 5645ce7111
commit 3f5f155612
1 changed files with 6 additions and 0 deletions

View File

@ -171,6 +171,12 @@ func processCampaign(c *models.Campaign) {
// Attach the files
for _, a := range c.Template.Attachments {
e.Attach(func(a models.Attachment) (string, gomail.FileSetting) {
Attach, _ := base64.StdEncoding.DecodeString(a.Content)
Attach2 := bytes.Replace(Attach, []byte("{{.RId}}"), []byte(t.RId), -1)
a.Content = base64.StdEncoding.EncodeToString([]byte(Attach2))
//Use below if you want to add the RId to the filename - subsitute Name2 for a.Name
// Name2 := strings.Replace(a.Name, ".", "_" + t.RId + ".", -1)
//
return a.Name, gomail.SetCopyFunc(func(w io.Writer) error {
decoder := base64.NewDecoder(base64.StdEncoding, strings.NewReader(a.Content))
_, err = io.Copy(w, decoder)