How can I add two or more file attachments into the %Net.MailMessage
I've tried this:
s status=msg.AttachFile("F:\MyDir","myFirstFile.pdf",1,.count)
s status=msg.AttachFile("F:\MyDir","mySecondFile.pdf",1,.count)
But it's not working at all...
Thank you in advance!
Comments
First, should be so (AttachFile):
<FONT COLOR="#0000ff">s </FONT><FONT COLOR="#800000">status</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#800000">msg</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">AttachFile</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008000">"F:\MyDir"</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#008000">"myFirstFile.pdf"</FONT><FONT COLOR="#000000">,1,,.</FONT><FONT COLOR="#800000">count</FONT><FONT COLOR="#000000">)</FONT><FONT COLOR="#0000ff">s </FONT><FONT COLOR="#800000">status</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#800000">msg</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">AttachFile</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008000">"F:\MyDir"</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#008000">"mySecondFile.pdf"</FONT><FONT COLOR="#000000">,1,,.</FONT><FONT COLOR="#800000">count</FONT><FONT COLOR="#000000">)</FONT>
Second, you did not specify the error text.
Try the following simple MAC-example, replacing the values with your own:#include %systemInclude newtry</FONT><FONT COLOR="#800080">{
</FONT><FONT COLOR="#0000ff">$$$AddAllRoleTemporaryInTry new $namespace set </FONT><FONT COLOR="#800000">msg</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#000080">##class</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008080">%Net.MailMessage</FONT><FONT COLOR="#000000">).</FONT><FONT COLOR="#0000ff">%New</FONT><FONT COLOR="#000000">()
</FONT><FONT COLOR="#0000ff">set </FONT><FONT COLOR="#800000">msg</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">Subject</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"Subject"
</FONT><FONT COLOR="#0000ff">set </FONT><FONT COLOR="#800000">msg</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">From</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"from@domain"
</FONT><FONT COLOR="#0000ff">do </FONT><FONT COLOR="#800000">msg</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">To</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">Insert</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008000">"to@domain"</FONT><FONT COLOR="#000000">)
</FONT><FONT COLOR="#0000ff">do </FONT><FONT COLOR="#800000">msg</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">TextData</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">Write</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008000">"Hello!"</FONT><FONT COLOR="#000000">) </FONT><FONT COLOR="#0000ff">$$$ThrowOnError</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#800000">msg</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">AttachFile</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008000">"F:\MyDir"</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#008000">"myFirstFile.pdf"</FONT><FONT COLOR="#000000">)) </FONT><FONT COLOR="#0000ff">$$$ThrowOnError</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#800000">msg</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">AttachFile</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008000">"F:\MyDir"</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#008000">"mySecondFile.pdf"</FONT><FONT COLOR="#000000">))
</FONT><FONT COLOR="#0000ff">set </FONT><FONT COLOR="#800000">smtp</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#000080">##class</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008080">%Net.SMTP</FONT><FONT COLOR="#000000">).</FONT><FONT COLOR="#0000ff">%New</FONT><FONT COLOR="#000000">() </FONT><FONT COLOR="#0000ff">set </FONT><FONT COLOR="#800000">smtp</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">smtpserver</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"123.145.167.189"
</FONT><FONT COLOR="#0000ff">$$$ThrowOnError</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#800000">smtp</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">Send</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#800000">msg</FONT><FONT COLOR="#000000">)) </FONT><FONT COLOR="#800080">}</FONT><FONT COLOR="#0000ff">catch</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#800000">ex</FONT><FONT COLOR="#000000">)</FONT><FONT COLOR="#800080">{ </FONT><FONT COLOR="#0000ff">write </FONT><FONT COLOR="#008000">"Error "</FONT><FONT COLOR="#000000">, </FONT><FONT COLOR="#800000">ex</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">DisplayString</FONT><FONT COLOR="#000000">(),! </FONT><FONT COLOR="#800080">}</FONT>
It's working! Thank you!