I have .net user control which will send email on click of button. Now, in email I want to send swf file embeded into the email. following is the code. But it does not show swf file in email.
protected void btnSubmit_Click(object sender, EventArgs e)
{
string body = "Dear Balvignan Team,\r\n\r\n";
if (txtComment.Text != null)
{
body = body + "Comment: " + txtComment.Text;
}
body=body + "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' ";
body=body + "codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0' width='425' height='300' align='middle'>";
body=body+ "<param name='movie' value='http://mydomain.com/images/ecards/CardCreative629.swf' />";
body=body + "<param name='quality' value='high' />";
body=body + "<param name='wmode' value='opaque' />";
body = body + "<embed src='http://mydomain.com/images/ecards/CardCreative629.swf' width='425' height='300' align='middle' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' wmode='opaque' ></embed>";
body = body + "</object>";
if (SendEmail(txtEmail.Text.Trim(), "Comment", body, true) == true)
{
lblContactAcknowledge.Text = "Thank You For <br />Submitting comment.";
lblContactAcknowledge.Visible = true;
PnlTalkToUs.Visible = false;
}
else
{
lblContactAcknowledge.Visible = false;
PnlTalkToUs.Visible = true;
}
}
SendEmail(string From, string Subject, string Message, bool IsHTML) is function which sends email.
That's because basically no email clients support Flash.
Here is a blog article covering this topic.
You can embed static images instead, and some clients (or webmail interfaces) allow animated ones aswell. But you should not expect a client to show flash content, and therefore shouldn't use it in emails either.
Related
I am creating an Android application with flutter/dart and I want to send an email with an embedded image inside.
So I installed flutter_email_sender and tried to use it. It works to send an email with text, but when I tried to add an image. It doesn't appear in the email application.
Here is my code:
// DataUser.pathImage is the path of the image (/data/src/0/cache/hi.jpg)
// extension(DataUser.pathImage).substring(1) => "jpg"
// DataUser.emailText.split("\n").join("<br>") is the text of the user that will be send
// ex: "Hi\nYes\nNo" => "Hi<br>Yes<br>No"
final bytes = File(DataUser.pathImage).readAsBytesSync();
String image64 = base64.encode(bytes);
String result = "<p>" + DataUser.emailText.split("\n").join("<br>") + "<br>";
result += "<img src=\"data:image/${extension(DataUser.pathImage).substring(1)};base64," + image64;
result += "\" alt=\"image\" />";
result += "</p>";
final Email email = Email(
body: result,
subject: "Pointage",
recipients: DataUser.adresse,
attachmentPaths: DataUser.filePath,
isHTML: true,
);
await FlutterEmailSender.send(email);
Is there a way to send an email containing an image with this extension?
In Email object, attachmentPaths accepts list of file paths i.e. List. You can check the complete example here.
Create a list of strings for attachments file paths:
List<String> attachments = [];
Now add your image path (string) to this list.
(I think you are doing a mistake by adding .readAsBytesSync(), I don't think that's necessary).
Let's say user picks an image from gallery:
PickedFile? pick = await picker.getImage(source: ImageSource.gallery);
if (pick != null) {
setState(() {
attachments.add(pick.path); //this line adds file path to attachments
});
}
Now pass this attachments list to the Email object.
Email(
body: result,
subject: "Pointage",
recipients: DataUser.adresse,
attachmentPaths: attachments,
isHTML: true,
);
much to my surprise I've successfully made an apps scripts that sends me email notifications when a specific cell is changed to 'Submitted,' but I have no idea how to make this identify the sheet it came from - have linked a copy of the sheet below, there are going to be around 20 of these, each with 6 submission sheets, and I need to do a thing as soon as the sheet has been marked submitted, i.e. same day. I'd rather not hard code in separate messages for each sheet, can I do something around getting the URL and sheet with the get active sheet coding and insert it into the email message? I'm also aware currently I've hard coded in the sheet names and therefore need 6 different triggers, I'm working on that - tried loads of different coding pages and this is the only one that worked!
https://docs.google.com/spreadsheets/d/1b0LOr9vhmFu4WtYy_RbS-1cvXncNOI_x3YT0f30fZgY/edit#gid=1979912158
Cheers,
Meg
function emailSubmit() {
MailApp.sendEmail("Testemail", "Test", "Test message");
}
function onEdit(e) {
const specificSheet = "Sub1"
const specificCell = "C11"
let sheetCheck = (e.range.getSheet().getName() == specificSheet)
let cellCheck = (e.range.getA1Notation() == specificCell)
if (!(sheetCheck && cellCheck) || e.value !== "Submitted") {
return;
}
else {
emailSubmit()
}
}
function onEdit2(e) {
const specificSheet = "Sub2"
const specificCell = "C11"
let sheetCheck = (e.range.getSheet().getName() == specificSheet)
let cellCheck = (e.range.getA1Notation() == specificCell)
if (!(sheetCheck && cellCheck)) {
return
}
else {
emailSubmit()
}
}
To obtain the spreadsheet object bound to the fired onEdit trigger, use the event object source
Sample:
function emailSubmit(spreadsheet, sheet) {
console.log("spreadsheet: " + spreadsheet);
console.log("sheet: " + sheet);
MailApp.sendEmail("Testemail", "Test", "Spreadsheet " + spreadsheet + " and tab " + sheet + "have been submitted");
}
function onEdit(e) {
const allowedSheets = ["Sub1","Sub2"];
const specificCell = "C11";
const spreadsheetName = e.source.getName();
const sheetName = e.range.getSheet().getName();
let sheetCheck = (allowedSheets.indexOf(sheetName) != -1);
let cellCheck = (e.range.getA1Notation() == specificCell);
if (!(sheetCheck && cellCheck) || e.value !== "Submitted") {
return;
}
else {
emailSubmit(spreadsheetName, sheetName);
}
}
References:
Event Objects
getName()
indexOf()
I'm building a little chat widget to my Blazor app. It works too, but to make it work more fluently, I'd like to make the focus stay in the InputText after submitting a message.
Any time I press enter, the message gets sent and received correctly. Unfortunately, the focus also goes wherever. This doesn't let you quickly type multiple messages into the chat.
I guess I could make a JS interop method sending the focus back to the InputText and call that after every submit, but I'd prefer to find a js-free solution.
My Razor markup is this:
<EditForm Model="message" OnSubmit="SendMessage">
<InputText type="text" #bind-Value="message.Message" />
</EditForm>
I send the message like this:
private async Task SendMessage()
{
Console.WriteLine("Send message " + message.Message);
var t = Service.SendMessage(message);
messages.Add(message);
message = new Library.Models.ChatMessage();
await t;
Console.WriteLine("Sending finished.");
}
This does not normally happen in an HTML form. The loss of focus is caused by the re-rendering of the tree.
As a workaround, not real pretty:
private async Task SendMessage()
{
Console.WriteLine("Send message " + message.Message);
var copy = new Library.Models.ChatMessage { Message = message.Message };
var t = Service.SendMessage(copy);
messages.Add(copy);
// message = new Library.Models.ChatMessage(); -- this was the problem
message.Message = "";
await t;
Console.WriteLine("Sending finished.");
}
I experimented a little with #key but I couldn't get that to work.
private string text;
void Start()
{
PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder().RequestIdToken().RequestServerAuthCode(false).Build();
text = "config created";
PlayGamesPlatform.InitializeInstance(config);
text = text + "\n" + "config initialized";
PlayGamesPlatform.Activate();
text = text + "\n" + "activated";
SignInWithPlayGames();
text = text + "\n" + "attempted to sign in";
}
public void SignInWithPlayGames()
{
UnityEngine.Social.localUser.Authenticate((bool success) =>
{
if (success)
{
string authCode = PlayGamesPlatform.Instance.GetServerAuthCode();
text = text + "\n" + "Auth code is: " + authCode;
if (string.IsNullOrEmpty(authCode))
{
text = text + "\n" + "Signed into Play Games Services but failed to get the server auth code.";
return;
}
}
if (!success)
{
text = text + "\n" + "Failed to Sign into Play Games Services.";
return;
}
});
}
When I run this on Unity, I got
config created
config initialized
activate
Failed to Sign into Play Games Services.
attempted to signed in
which is fine since I am using my PC to test it. But I got an interesting result after I run my app on a real device. I got this:
config created
config initialized
activate
attempted to signed in
I think it skip if (success) from public void SignInWithPlayGames() method. My app never shows Google Play UI and I am not sure now if I am using the right code.
I've struggled quite a bit with Google Play in the last few weeks. I did not Retrieve the ID token or auth token in the builder however. It might be causing you problems.
Also, you need to cast the social user into a google user to access its properties.
I got it to work with the following code. (If you do not get it to work with this code, the problem resides in your settings in the googleplay Plugin and/or google play console.)
PlayGamesClientConfiguration config = new
PlayGamesClientConfiguration.Builder()
.Build();
// Enable debugging output (recommended)
PlayGamesPlatform.DebugLogEnabled = true;
PlayGamesPlatform.InitializeInstance(config);
PlayGamesPlatform.Activate();
Social.localUser.Authenticate((bool success) =>
{
var googleUser = ((PlayGamesLocalUser)Social.localUser);
if (googleUser.authenticated)
{
// access googleUser properties and store them or use them
}
}
I developing a window app where it can get all my Facebook profile wall posts and display it on the list box. I downloaded the codes from http://www.youtube.com/watch?v=5lC7Q2Z2yik but my Facebook wall posts are still not displaying. I can post on my wall through my application, my profile picture and friends are successfully displayed. is there anything I forgot to change/add? any help would be greatly appreciated!
private void getMyWallData()
{
apiService.AccessToken = myToken.Default.token;
JSONObject myWallFeed = apiService.Get("/me/feed");
var wallData = myWallFeed.Dictionary["data"];
List<JSONObject> myFeeds = wallData.Array.ToList<JSONObject>();
foreach (var p in myFeeds)
{
try
{
if (p.Dictionary.ContainsKey("message"))
{
Console.WriteLine(p.Dictionary["message"].String + " " + p.Dictionary["created_time"].String);
listBoxMyWall.Items.Add(p.Dictionary["message"].String);
listBoxMyWall.Items.Add("");
}
if (p.Dictionary.ContainsKey("comments"))
{
listBoxMyWall.Items.Add(" " + p.Dictionary["comments"].Dictionary["data"].Array[0].Dictionary["from"].Dictionary["name"].String + " " + p.Dictionary["comments"].Dictionary["data"].Array[0].Dictionary["message"].String);
listBoxMyWall.Items.Add("");
}
}
catch (KeyNotFoundException ex)
{
MessageBox.Show(ex.Message);
}
}
}