NetTalk Central

Author Topic: Rename Attacment when downloaded  (Read 3240 times)

debraballenger

  • Newbie
  • *
  • Posts: 49
    • View Profile
    • Email
Rename Attacment when downloaded
« on: November 14, 2013, 10:47:26 AM »
I am using the NetEmailReceive and when I downloadi the attachments, I want to rename the file to contain an ID so that 2 files are never named the same thing.

What embed point can I do this change in?

Thanks!
Debra

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11181
    • View Profile
Re: Rename Attacment when downloaded
« Reply #1 on: November 15, 2013, 01:47:02 AM »
NetEmail._SaveFile Procedure (*string writeString, string fileName, long dataLen=0)

In other words, before the parent call, make your own call to the Parent using a different second parameter (then return before the generated parent call)

For example

thisEmail._SaveFile Procedure (*string writeString, string fileName, long dataLen=0)
somename  string(255)
  code
  somename  = clip(fileName)   random(100000,999999) ! clearly nonsense, because of the extension
  parent._SaveFile (writeString,somename ,dataLen)  ! generated parent call
  return

  parent._SaveFile (writeString,fileName,dataLen)  ! generated parent call


Setting of Somename is a bit more complicated because you need to remove the extension part of the name, change the name, put the extension back. But you get the idea.

Wolfgang Orth

  • Sr. Member
  • ****
  • Posts: 251
    • View Profile
    • oData Wolfgang Orth
Re: Rename Attacment when downloaded
« Reply #2 on: January 23, 2014, 03:42:38 AM »

somename  =   FORMAT(TODAY(), D10-) &'_'& FORMAT(CLOCK(), @T04-) &'_'&  random(100000,999999)  &'_'&  clip(fileName)


like:
2014-01-23_21-32-54_12345678_filename.XLS
« Last Edit: January 23, 2014, 01:06:36 PM by Wolfgang Orth »