Skip to content

Commit

Permalink
Create email.js
Browse files Browse the repository at this point in the history
document.getElementById('contact-form').addEventListener('submit', function(event) {
      event.preventDefault();

      // Prepare the data to be sent
      const formData = new FormData(this);
      const templateParams = {
        from_name: `${formData.get('first_name')} ${formData.get('last_name')}`,
        to_name: 'Abbas Uddin'
        ,
        email: formData.get('email'),
        reply_to: formData.get('email'),
        message: formData.get('comments'),
      };

      // Send the email
      emailjs.send('service_eg730jo', 'template_9i94an9', templateParams)
        .then(function() {
          alert('Email sent successfully!');
        }, function(error) {
          alert('Failed to send email. Error: ' + JSON.stringify(error));
        });
    });
  • Loading branch information
CodeAbbas authored Jul 12, 2024
1 parent cebb999 commit f04d3b8
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions scipts/email.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
document.getElementById('contact-form').addEventListener('submit', function(event) {
event.preventDefault();

// Prepare the data to be sent
const formData = new FormData(this);
const templateParams = {
from_name: `${formData.get('first_name')} ${formData.get('last_name')}`,
to_name: 'Abbas Uddin'
,
email: formData.get('email'),
reply_to: formData.get('email'),
message: formData.get('comments'),
};

// Send the email
emailjs.send('service_eg730jo', 'template_9i94an9', templateParams)
.then(function() {
alert('Email sent successfully!');
}, function(error) {
alert('Failed to send email. Error: ' + JSON.stringify(error));
});
});

0 comments on commit f04d3b8

Please sign in to comment.