Pessoal, tenho o seguinte código feito no Outlook com uma regra criada para todo email que chega rodar a script abaixo:
gravar numa variável para que eu possa utilizá-la como nome do arquivo a ser salvo.
Antecipadamente agradeço a ajuda.
Abaixo segue o xml com a tag chnfe.
- Código:
Sub SaveAttachments(myMail As MailItem)
Dim vFrom As String, vSubject As String
Dim vFile As Attachment
vFrom = myMail.SenderEmailAddress
vSubject = myMail.Subject
If myMail.Attachments.Count > 0 Then
For i = 1 To myMail.Attachments.Count
Set vFile = myMail.Attachments(i)
If LCase(vFile.FileName) Like "*.xml" Then
vFile.SaveAsFile "C:\Test\" & Replace(vSubject, ":", "") + ".xml"
End If
Next i
End If
Set myMail = Nothing
Set vFile = Nothing
End Sub
Antecipadamente agradeço a ajuda.
Abaixo segue o xml com a tag chnfe.
- Código:
<?xml version="1.0" encoding="utf-8"?>
<nfeProc versao="2.00" xmlns="http://www.portalfiscal.inf.br/nfe">
<NFe xmlns="http://www.portalfiscal.inf.br/nfe">
<infNFe Id="NFe35120102634915000265550010000471411400843132" versao="2.00">
<ide>
<cUF>35</cUF>
<cNF>40084313</cNF>
<natOp>VENDAS PROPRIAS</natOp>
<indPag>0</indPag>
<mod>55</mod>
<serie>1</serie>
<nNF>47141</nNF>
<dEmi>2012-01-21</dEmi>
<dSaiEnt>2012-01-21</dSaiEnt>
<hSaiEnt>11:08:54</hSaiEnt>
<tpNF>1</tpNF>
<cMunFG>3513504</cMunFG>
<tpImp>1</tpImp>
<tpEmis>1</tpEmis>
<cDV>2</cDV>
<tpAmb>1</tpAmb>
<finNFe>1</finNFe>
<procEmi>0</procEmi>
<verProc>QAD</verProc>
</ide>
<emit>
<CNPJ>02634915000265</CNPJ>
<xNome>COLUMBIAN CHEMICALS BRASIL LTDA</xNome>
<xFant>COLUMBIAN CHEMICALS BRASIL L</xFant>
<enderEmit>
<xLgr>EST RENE FONSECA</xLgr>
<nro>S/N</nro>
<xCpl>POLO INDUSTRIAL</xCpl>
<xBairro>PIACAGUERA</xBairro>
<cMun>3513504</cMun>
<xMun>CUBATAO</xMun>
<UF>SP</UF>
<CEP>11573904</CEP>
<cPais>1058</cPais>
<xPais>BRASIL</xPais>
<fone>1333627100</fone>
</enderEmit>
<IE>283043308116</IE>
<CRT>3</CRT>
</emit>
<dest>
<CNPJ>87870952000144</CNPJ>
<xNome>BORRACHAS VIPAL SA</xNome>
<enderDest>
<xLgr>RUA BUARQUE DE MACEDO, 365</xLgr>
<nro>-</nro>
<xBairro>CENTRO</xBairro>
<cMun>4313300</cMun>
<xMun>NOVA PRATA</xMun>
<UF>RS</UF>
<CEP>95320000</CEP>
<cPais>1058</cPais>
<xPais>BRASIL</xPais>
<fone>542421745</fone>
</enderDest>
<IE>0850007682</IE>
<email>recfiscal.borrachasNP@vipal.com.br,</email>
</dest>
<entrega>
<CNPJ>87870952000144</CNPJ>
<xLgr>RUA BUARQUE DE MACEDO, 365</xLgr>
<nro>_</nro>
<xBairro>CENTRO</xBairro>
<cMun>4313300</cMun>
<xMun>NOVA PRATA</xMun>
<UF>RS</UF>
</entrega>
<det nItem="1">
<prod>
<cProd>n550-5095</cProd>
<cEAN/>
<xProd>STATEX N550 - BIG BAG(2.20m)</xProd>
<NCM>28030019</NCM>
<CFOP>6101</CFOP>
<uCom>T</uCom>
<qCom>20.6420</qCom>
<vUnCom>6376.3307049914</vUnCom>
<vProd>131620.22</vProd>
<cEANTrib/>
<uTrib>T</uTrib>
<qTrib>20.6420</qTrib>
<vUnTrib>6376.3307049914</vUnTrib>
<indTot>1</indTot>
</prod>
<imposto>
<ICMS>
<ICMS00>
<orig>0</orig>
<CST>00</CST>
<modBC>3</modBC>
<vBC>131620.22</vBC>
<pICMS>12.00</pICMS>
<vICMS>15794.43</vICMS>
</ICMS00>
</ICMS>
<IPI>
<cEnq>999</cEnq>
<IPINT>
<CST>51</CST>
</IPINT>
</IPI>
<PIS>
<PISAliq>
<CST>01</CST>
<vBC>131620.22</vBC>
<pPIS>1.65</pPIS>
<vPIS>2171.73</vPIS>
</PISAliq>
</PIS>
<COFINS>
<COFINSAliq>
<CST>01</CST>
<vBC>131620.22</vBC>
<pCOFINS>7.60</pCOFINS>
<vCOFINS>10003.14</vCOFINS>
</COFINSAliq>
</COFINS>
</imposto>
<infAdProd>_</infAdProd>
</det>
<total>
<ICMSTot>
<vBC>131620.22</vBC>
<vICMS>15794.43</vICMS>
<vBCST>0.00</vBCST>
<vST>0.00</vST>
<vProd>131620.22</vProd>
<vFrete>0.00</vFrete>
<vSeg>0.00</vSeg>
<vDesc>0.00</vDesc>
<vII>0.00</vII>
<vIPI>0.00</vIPI>
<vPIS>2171.73</vPIS>
<vCOFINS>10003.14</vCOFINS>
<vOutro>0.00</vOutro>
<vNF>131620.22</vNF>
</ICMSTot>
<ISSQNtot/>
<retTrib/>
</total>
<transp>
<modFrete>0</modFrete>
<transporta>
<CNPJ>01501729000104</CNPJ>
<xNome>TRANSPORTADORA SANA LTDA</xNome>
<IE>0750031697</IE>
<xEnder>RUA LAURO RICIERI BORTOLON,</xEnder>
<xMun>MARAU</xMun>
<UF>RS</UF>
</transporta>
<veicTransp>
<placa>IKQ7871</placa>
<UF>RS</UF>
</veicTransp>
<vol>
<qVol>20</qVol>
<esp>BAGS</esp>
<pesoL>20642.000</pesoL>
<pesoB>20722.000</pesoB>
</vol>
</transp>
<cobr>
<fat>
<nFat>128039</nFat>
<vOrig>131620.22</vOrig>
<vLiq>131620.22</vLiq>
</fat>
<dup>
<nDup>1</nDup>
<dVenc>2012-01-21</dVenc>
<vDup>131620.22</vDup>
</dup>
</cobr>
<infAdic/>
</infNFe>
<Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
<SignedInfo>
<CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/>
<SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/>
<Reference URI="#NFe35120102634915000265550010000471411400843132">
<Transforms>
<Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/>
<Transform Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/>
</Transforms>
<DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
<DigestValue>VW603DYpKw2PInUc631ZCj5jGXM=</DigestValue>
</Reference>
</SignedInfo>
<SignatureValue>OD7CMYzmqsu3dXYJSG/btHwMDy6IPenrzSMxNgdgfYVVKUdJO75gfS1C2FL+5CfBuE5ihv50l8SMz87BkLkwhdM8izbpiRbYRpsY/qzDO2Khrjeq3Yjl8+5ed6QA/fUPSSJG9ilFq6HjQQ/Z2xsVlFRxGp2fTlDLSJg692re23g=</SignatureValue>
<KeyInfo>
<X509Data>
<X509Certificate>MIIGXzCCBUegAwIBAgIIYkDSVFfhdNgwDQYJKoZIhvcNAQEFBQAwdTELMAkGA1UEBhMCQlIxEzARBgNVBAoTCklDUC1CcmFzaWwxNjA0BgNVBAsTLVNlY3JldGFyaWEgZGEgUmVjZWl0YSBGZWRlcmFsIGRvIEJyYXNpbCAtIFJGQjEZMBcGA1UEAxMQQUMgU0VSQVNBIFJGQiB2MTAeFw0xMTEwMjUxNTE4NDBaFw0xMjEwMjQxNTE4NDBaMIHeMQswCQYDVQQGEwJCUjELMAkGA1UECBMCU1AxEDAOBgNVBAcTB0NVQkFUQU8xEzARBgNVBAoTCklDUC1CcmFzaWwxNjA0BgNVBAsTLVNlY3JldGFyaWEgZGEgUmVjZWl0YSBGZWRlcmFsIGRvIEJyYXNpbCAtIFJGQjEWMBQGA1UECxMNUkZCIGUtQ05QSiBBMTESMBAGA1UECxMJQVIgU0VSQVNBMTcwNQYDVQQDEy5DT0xVTUJJQU4gQ0hFTUlDQUxTIEJSQVNJTCBMVERBOjAyNjM0OTE1MDAwMjY1MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDTRjavglPQY5Dw8xDnrk4Ivgdh9DoxAyzoHT0aImZDuKYnh9u+8LYm+t8J/Fhu6TO/IOqLI8TmCvTlmwdxrMoJEIjI3D73s0h8nsc90vAk/m7O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2NzcC5jZXJ0aWZpY2Fkb2RpZ2l0YWwuY29tLmJyL3NlcmFzYXJmYnYxMA0GCSqGSIb3DQEBBQUAA4IBAQBMS8IoCSuLxWgjhBDEjznHAPR+iDf4jR66h2gfDpgAkV1uLQKoWHc0CK/U7h/Z3BknpWAxUOxeYl4SzqtmkEz7JO+vMGq/8j+n4oJiCIm7VL9acvL31P+vLHm6JvRn/TEqmEJRFjX+hgPX/M8tdfdPSEpySaYJQ6fUlJMNxmMmkjoXma+lCMnEIKZjMDOkXOggtIigX8TUyhP73pxfzotDSWPCb7g5MM2h3/1dmG5ILnIIQlTYLIzbnY3qeaarFb98EwFKBa4q5uu2kNw4Rs2E23s3jxPiq30hGhTa3pJqQpIgNrAMhCDUytmvfgwL7hkXVbm6ifMpD+4n2z+Ll73P</X509Certificate>
</X509Data>
</KeyInfo>
</Signature>
</NFe>
<protNFe versao="2.00" xmlns="http://www.portalfiscal.inf.br/nfe">
<infProt>
<tpAmb>1</tpAmb>
<verAplic>SP_NFE_PL_006j</verAplic>
<chNFe>35120102634915000265550010000471411400843132</chNFe>
<dhRecbto>2012-01-21T11:08:59</dhRecbto>
<nProt>135120037939922</nProt>
<digVal/>
<cStat>100</cStat>
<xMotivo>Autorizado o uso da NF-e</xMotivo>
</infProt>
</protNFe>
</nfeProc>
- Código: