Derek, Matt — thank you for your answers.
I wasn’t able to reply earlier due to other work, sorry about that.
I tried using the AddAttachment API.
Since I am already familiar with SMTP, I am focusing on implementing this through the API instead.
This is my API written in C#:
var uri = MyDomain + "api/v1/mail/attachment";
var token = HttpContext.Current.Session["Token"].ToString();
var serializer = new JavaScriptSerializer();
var input_attachmentID = "attach1";
var input_CID = "cid1";
//uri = uri + "/" + input_attachmentID;
uri = uri + "/" + input_attachmentID + "/" + input_CID;
try
{
var input_post = new
{
};
var json = JsonConvert.SerializeObject(input_post);
byte[] result = Encoding.UTF8.GetBytes(json.ToString());
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
request.Method = "POST";
request.ContentType = "application/json;charset=UTF-8";
request.ContentLength = result.Length;
request.Headers["Authorization"] = "Bearer " + token;
Stream postDataStream = request.GetRequestStream();
postDataStream.Write(result, 0, result.Length);
postDataStream.Close();
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
using (var reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8))
{
return reader.ReadToEnd();
}
}
The request is returning a 500 Error, which makes me think that my URL might be incorrect. However, other APIs on the same domain are working fine, so I don’t believe it’s a domain or server issue.
I assumed that the attachmentID could be set arbitrarily, but perhaps my approach is incorrect?
If I want to retrieve a file from the server or from my local machine, should I pass that file as a parameter in the request?”