title: How to set confidential mode with one week expiry in gmail powershell script?
body: <p>I am using a PowerShell script to send emails. I need help that how can I set confidential mode with one-week expiry so that after one week the email should be deleted from the receiver's inbox.</p>
  <p>Below is the code which is being used currently by me. please help to modify the same.</p>
  <pre><code>@ECHO OFF
  
  SET GmailAccount=%~1
  SET GmailPassword=%~2
  SET Attachment=%~3
  setlocal
  set &quot;date=%date%&quot;
  
  CALL :PowerShell
  CD /D &quot;%PowerShellDir%&quot;
  Powershell -ExecutionPolicy Bypass -Command &quot;&amp; '%PSScript%' 'abc@gmail.com' 'password' 'abcfilename.xlsx'&quot;
  EXIT
  
  :PowerShell
  SET PowerShellDir=C:\Windows\System32\WindowsPowerShell\v1.0
  SET PSScript=%temp%\~tmpSendeMail.ps1
  IF EXIST &quot;%PSScript%&quot; DEL /Q /F &quot;%PSScript%&quot;
  
  ECHO $Username      = $args[0]&gt;&gt; &quot;%PSScript%&quot;
  ECHO $EmailPassword = $args[1]&gt;&gt; &quot;%PSScript%&quot;
  ECHO $Attachment    = $args[2]&gt;&gt; &quot;%PSScript%&quot;
  ECHO                          &gt;&gt; &quot;%PSScript%&quot;
  ECHO $Username    = $Username                 &gt;&gt; &quot;%PSScript%&quot;
  ECHO $EmailTo     = &quot;receipient@gmail.com&quot; &gt;&gt; &quot;%PSScript%&quot;
  ECHO $EmailFrom   = &quot;abc@gmail.com&quot; &gt;&gt; &quot;%PSScript%&quot;
  ECHO $Subject     = &quot;Sybject Name - %date%&quot;           &gt;&gt; &quot;%PSScript%&quot;
  ECHO $Body        = &quot;Dear User Text body&quot;              &gt;&gt; &quot;%PSScript%&quot;
  ECHO $SMTPServer  = &quot;smtp.gmail.com&quot;          &gt;&gt; &quot;%PSScript%&quot;
  ECHO $SMTPMessage = New-Object System.Net.Mail.MailMessage($EmailFrom, $EmailTo, $Subject, $Body) &gt;&gt; &quot;%PSScript%&quot;
  ECHO $Attachment  = New-Object System.Net.Mail.Attachment($Attachment)                            &gt;&gt; &quot;%PSScript%&quot;
  ECHO $SMTPMessage.Attachments.Add($Attachment)                                                    &gt;&gt; &quot;%PSScript%&quot;
  ECHO $SMTPClient = New-Object Net.Mail.SmtpClient($SmtpServer, 587)                               &gt;&gt; &quot;%PSScript%&quot;
  ECHO $SMTPClient.EnableSsl = $true                                                                &gt;&gt; &quot;%PSScript%&quot;
  ECHO $SMTPClient.Credentials = New-Object System.Net.NetworkCredential($Username, $EmailPassword) &gt;&gt; &quot;%PSScript%&quot;
  ECHO $SMTPClient.Send($SMTPMessage)                                                               &gt;&gt; &quot;%PSScript%&quot;
  GOTO :EOF
  PAUSE
  </code></pre>