Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

C_ code for message creation

...
// creo l'opzione "note"
it.mailupnet.services.Option optNote = new it.mailupnet.services.Option();
optNote.Key = "note";
optNote.Value = "Queste sono le note"; 
// allego un file al messaggio
// 1. Leggo il messaggio ed effettuo l'encoding in base 64 del contenuto
FileStream fs = new FileStream(@"C:\mydir\webservice.docx", 
FileMode.Open, FileAccess.Read);
byte[] filebytes = new byte[fs.Length];
fs.Read(filebytes, 0, Convert.ToInt32(fs.Length));
string encodedData = Convert.ToBase64String(filebytes,
Base64FormattingOptions.InsertLineBreaks);
// 2. Creao l'opzione attach01_name" che conterrĂ  il nome del file
it.mailupnet.services.Option optAttach01Name = 
new it.mailupnet.services.Option();
optAttach01Name.Key = "attach01_name";
optAttach01Name.Value = "test.docx";
// 3. Creao l'opzione attach01_data" che conterrĂ  il contenuto del file
it.mailupnet.services.Option optAttach01Data = 
new it.mailupnet.services.Option();
optAttach01Data.Key = "attach01_data";
optAttach01Data.Value = encodedData; 
// creo l'array delle opzioni di invio
it.mailupnet.services.Option[] options = new it.mailupnet.services.Option[3];
options[0] = optNote;
options[1] = optAttach01Name;
options[2] = optAttach01Data; 
string html = "codice HTML del messaggio";
string s = myService.CreateNewsletter(accessKey, 
1, "WebService // Newsletter da HTML", "HTML", html, options);
... if (errorCode == 0)
{
// eseguo il parsing del messaggio di ritorno per ricavare il codice
// identificatico del messaggio creato
}
  • No labels